There is a error in my code, can anyone help me please?
My code:
function funP(u, τ::Float64)
w = (τ*max(u, 0)) + ((1-τ)*max(-u, 0))
return w
end
τ = 0.2
modelquant = Model(with_optimizer(OSQP.Optimizer))
@variable(modelquant, β[i=0:1])
@variable(modelquant, erro[1:T])
@constraint(modelquant,[i=1:T], erro[i] >= contratos[i] - β[0] - β[1]*spot[i])
@constraint(modelquant,[i=1:T], erro[i] >= -contratos[i] + β[0] + β[1]*spot[i])
@objective(modelquant, Min, sum(funP(erro[i], τ) for i=1:T))
optimize!(modelquant)
objective_value(modelquant)
= JuMP.value.(β)
The error is:
julia> @objective(modelquant, Min, sum(funP(erro[i], τ) for i=1:T)) ERROR: MethodError: no method matching isless(::Int64, ::VariableRef) Closest candidates are: isless(::Missing, ::Any) at missing.jl:87 isless(::Real, ::AbstractFloat) at operators.jl:166 isless(::Integer, ::ForwardDiff.Dual{Ty,V,N} where N where V) where Ty at C:\Users\Fernanda.julia\packages\ForwardDiff\kU1ce\src\dual.jl:140 ... Stacktrace: [1] max(::VariableRef, ::Int64) at .\operators.jl:417 [2] funP(::VariableRef, ::Float64) at .\REPL[8]:2 [3] macro expansion at C:\Users\Fernanda.julia\packages\MutableArithmetics\bPWR4\src\rewrite.jl:276 [inlined] [4] macro expansion at C:\Users\Fernanda.julia\packages\JuMP\qhoVb\src\macros.jl:830 [inlined] [5] top-level scope at .\REPL[20]:1
Thank you so much!