The following is my code :
using JuMP, AmplNLWriter
m = Model(() -> AmplNLWriter.Optimizer("Your_Path\\lindoapi\\bin\\win64\\runlindo.exe"))
@variable(m, -2 <= x1 <= 2,Int)
@variable(m, -2 <= x2 <= 2)
@constraint(m, -2*x1 - x2 <= 2)
@constraint(m, -x1 - 2*x2 <= 2)
@constraint(m, x1^2 + x2^2 <= 1)
@objective(m, Min, (x1+x2)/(2+x1^2+x2^2))
write_to_file(m,"type4CONF.nl")
println(m)
optimize!(m)
value(x1)
value(x2)
objective_value(m)
solution_summary(m)
Firstly, lindoapi can solve this model, but it can not output the solutions. Some errors:
julia> value(x1)
ERROR: Result index of attribute MathOptInterface.VariablePrimal(1) out of bounds. There are currently 0 solution(s) in the model.
and
julia> solution_summary(m)
* Solver : AmplNLWriter
* Status
Result count : 0
Termination status : OTHER_ERROR
Message from the solver:
"Error calling the solver. Failed with: SystemError("opening file \"D:\\\\Temp\\\\jl_ugJoB7\\\\model.sol\"", 2, nothing)"
* Candidate solution (result #1)
Primal status : NO_SOLUTION
Dual status : NO_SOLUTION
* Work counters
Solve time (sec) : 4.54000e-01
But, if i revised it with
m = Model(() -> AmplNLWriter.Optimizer("Your_Path\\lindoapi\\bin\\win64\\runlindo.exe",["-sol"]))
Every things is OK.
So, what is wrong with this errors? Thanks very much.
Sincerely,
J. Wang.