chkwon / Complementarity.jl

provides a modeling interface for mixed complementarity problems (MCP) and math programs with equilibrium problems (MPEC) via JuMP
Other
75 stars 20 forks source link

Having trouble to solve same problem twice or more #28

Closed AndradeTiago closed 6 years ago

AndradeTiago commented 6 years ago

Hello,

I'm having some trouble solve the same problem twice without rewriting the entire model

Here an example:


using Complementarity using JuMP

m = MCPModel()

@variable(m, x>=0) @mapping(m, F1, 2-x) @complementarity(m, F1, x)

solveLCP(m) solveLCP(m)


In the second solve attempt, it returns the following error message. It happens independently if I'm trying to solve each attempt with path or nlsolve.


BoundsError: attempt to access 1-element Array{Float64,1} at index [2] eval_g(::JuMP.NLPEvaluator, ::Array{Float64,1}, ::Array{Float64,1}) at nlp.jl:557 myfunc at mcp.jl:95 [inlined] (::FunctionWrappers.CallWrapper{Array{Float64,1}})(::Complementarity.#myfunc#4{JuMP.Model}, ::Array{Float64,1}) at FunctionWrappers.jl:49 macro expansion at FunctionWrappers.jl:100 [inlined] do_ccall at FunctionWrappers.jl:91 [inlined] FunctionWrapper at FunctionWrappers.jl:106 [inlined] f_user_wrap(::Int32, ::Ptr{Float64}, ::Ptr{Float64}) at PATHSolver.jl:170

solveLCP#8(::Bool, ::Function, ::Function, ::SparseMatrixCSC{Float64,Int64}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{String,1}, ::Array{String,1}, ::Array{Float64,1}) at PATHSolver.jl:134

_solve_path#3(::Bool, ::Function, ::JuMP.Model) at mcp.jl:151

(::Complementarity.#kw##_solve_path)(::Array{Any,1}, ::Complementarity.#_solve_path, ::JuMP.Model) at :0

solveMCP#1(::Symbol, ::Symbol, ::Bool, ::Function, ::JuMP.Model) at mcp.jl:66

(::Complementarity.#kw##solveMCP)(::Array{Any,1}, ::Complementarity.#solveMCP, ::JuMP.Model) at :0 solveLCP(::JuMP.Model) at mcp.jl:73 include_string(::String, ::String) at loading.jl:522 include_string(::String, ::String, ::Int64) at eval.jl:30 include_string(::Module, ::String, ::String, ::Int64, ::Vararg{Int64,N} where N) at eval.jl:34 (::Atom.##100#105{String,Int64,String})() at eval.jl:75 withpath(::Atom.##100#105{String,Int64,String}, ::Void) at utils.jl:30 withpath(::Function, ::String) at eval.jl:38 hideprompt(::Atom.##99#104{String,Int64,String}) at repl.jl:65 macro expansion at eval.jl:73 [inlined] (::Atom.##98#103{Dict{String,Any}})() at task.jl:80


chkwon commented 6 years ago

Thanks. I need to look into this issue. Will need some time though.

chkwon commented 6 years ago

Model reuse should now work in the master branch. However, it is still experimental. If you find any error or issue, please let me know.