Ok, i will look into it, thanks for the reply!
I tried adding another constraint to my problem. Like this:
using JuMP, CouenneNL
Nt = 2;
L = 0;
C = 0;
h = 0;
hmax = 5;
Yh = zeros(Nt,Nt,hmax);
b = 2;
for h = 3:2:hmax
for L = 1:Nt
for C = 1:Nt
Yh[L,C,h] = b*h;
b = b+1;
end
end
b = 2;
end
Ih = [2 1 3 4 5; 7 5 6.5 3 10];
u = [10;14];
kj = 1;
Qmod = 50;
hsmin = 3*ones(Nt,1);
hsmax = 25*ones(Nt,1);
m = Model(solver=CouenneNLSolver())
@variable(m, hsmin[i] <= hs[i=1:Nt] <= hsmax[i], Int)
@variable(m, hs_dummy[i=1:Nt], Int)
@variable(m, Vh[i = 1:Nt,h = 3:2:hmax])
@variable(m, DHTv[i = 1:Nt])
@NLobjective(m, Min, sum(10*hs[i] for i = 1:Nt))
@constraint(m, hs[i = 1:Nt] .== 2 * hs_dummy[i] + 1)
@constraint(m, con[i = 1:Nt,h = 3:2:hmax], Yh[i,i,h]*Vh[i,h] == Ih[i,h])
@constraint(m, conn[i = 1:Nt, h = 3:2:hmax], DHTv[i] == sum(Vh[i,h]^2)/u[i]^2) # New Constraint added
status = solve(m)
println("Objective value: ", getobjectivevalue(m))
println("hs = ", getvalue(hs))
println("Vh = ", getvalue(Vh))
println("DHTv = ", getvalue(DHTv))
But i’m getting the following error:
ERROR: LoadError: AssertionError: line[1:7] == "Options"
Stacktrace:
[1] read_sol(::IOStream, ::AmplNLWriter.AmplNLMathProgModel) at C:\Users\Muril\.julia\v0.6\AmplNLWriter\src\AmplNLWriter.jl:666
[2] read_results(::IOStream, ::AmplNLWriter.AmplNLMathProgModel) at C:\Users\Muril\.julia\v0.6\AmplNLWriter\src\AmplNLWriter.jl:575
[3] open(::AmplNLWriter.##117#118{AmplNLWriter.AmplNLMathProgModel}, ::String, ::String) at .\iostream.jl:152
[4] read_results(::AmplNLWriter.AmplNLMathProgModel) at C:\Users\Muril\.julia\v0.6\AmplNLWriter\src\AmplNLWriter.jl:569
[5] optimize!(::AmplNLWriter.AmplNLMathProgModel) at C:\Users\Muril\.julia\v0.6\AmplNLWriter\src\AmplNLWriter.jl:419
[6] optimize!(::CouenneNL.CouenneNLNonlinearModel) at C:\Users\Muril\.julia\v0.6\Lazy\src\macros.jl:268
[7] #solvenlp#165(::Bool, ::Function, ::JuMP.Model, ::JuMP.ProblemTraits) at C:\Users\Muril\.julia\v0.6\JuMP\src\nlp.jl:1271
[8] (::JuMP.#kw##solvenlp)(::Array{Any,1}, ::JuMP.#solvenlp, ::JuMP.Model, ::JuMP.ProblemTraits) at .\<missing>:0
[9] #solve#116(::Bool, ::Bool, ::Bool, ::Array{Any,1}, ::Function, ::JuMP.Model) at C:\Users\Muril\.julia\v0.6\JuMP\src\solvers.jl:172
[10] solve(::JuMP.Model) at C:\Users\Muril\.julia\v0.6\JuMP\src\solvers.jl:150
[11] include_string(::String, ::String) at .\loading.jl:522
[12] include_string(::Module, ::String, ::String) at C:\Users\Muril\.julia\v0.6\Compat\src\Compat.jl:88
[13] (::Atom.##112#116{String,String})() at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:109
[14] withpath(::Atom.##112#116{String,String}, ::String) at C:\Users\Muril\.julia\v0.6\CodeTools\src\utils.jl:30
[15] withpath(::Function, ::String) at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:38
[16] hideprompt(::Atom.##111#115{String,String}) at C:\Users\Muril\.julia\v0.6\Atom\src\repl.jl:67
[17] macro expansion at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:106 [inlined]
[18] (::Atom.##110#114{Dict{String,Any}})() at .\task.jl:80
while loading C:\Users\Muril\Desktop\Murilo\UFPE\Dissertação\Julia\Arquivos Feitos\teste_otimização_matriz_3_dimensões.jl, in expression starting on line 56
Does this mean that my problem is now infeasible?
I’m not worried at the moment if the problem is feasible or not, i’m just trying to learn how to write those @variable
, @constraint
and @objective
macros.
Is this written correct? I mean, it would work, if the supposed infeasibility of the problem wasn’t causing the error here?
@constraint(m, conn[i = 1:Nt, h = 3:2:hmax], DHTv[i] == sum(Vh[i,h]^2)/u[i]^2) # New Constraint added