Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

great package #1

Open
Jovansam opened this issue May 15, 2020 · 6 comments
Open

great package #1

Jovansam opened this issue May 15, 2020 · 6 comments

Comments

@Jovansam
Copy link

Hi this is a really great package. I would like to take advantage of my GAMS solvers. What version of Julia-JuMP does this work with? I cannot get it to work in the latest (Julia 1.4.1 and JuMP v0.21.1). Thx in advance

@xhub
Copy link
Owner

xhub commented May 17, 2020

Thanks for your interest, and taking the time for a opening a bug report.

I've released today v0.1.1, I hope it fixes the issue (at least temporary). I sucessfully tested with the same configuration on Linux, MacOs, and windows (the appveyor CI is in a bad shape, but on a real machine it works).

I've also improved the README. It's not a proper documentation but it is already something.

For the details: I realized that there was likely a mismatch between the library and the julia code.
I did some changes on the library in since the first release. There may be a mismatch here.
I create a JLL package for the library, it just got merged, I need to still work on the logic to then use this package to ensure that a release version always gets the right version of the library through an exact JLL dependency.

If there are still some issues, just a few question to help debugging

  • Are you using master or the version 0.1.1 ?
  • Which OS ?
  • Is the "gams" executable in the PATH (that is executable from a terminal or cmd.exe)?
  • Does it complaint about a non-existing function in libreshop ?

I am getting close to finish a full MOI backend, also supporting the direct_model, which is nice for large scale models, if you solve any of those. Right now in direct_model, there is still some missing MOI functions, and some errors pops up, but they mostly for displaying info, so it still solves.

The options for the GAMS solvers are not being passed right now, it is also on top of the TODO list to support setting the options for a GAMS solver through JuMP.

Out of curiosity what kind of problems/solvers would you wish to use? As you may have seen, the documentation is unfortunately rather sparse. I've had some issues with some solvers on Mac OS and windows, which do not show up in real workload or setup. Part of it is due to limitation on the CI images. But there could be issues on real machines as well.

@Jovansam
Copy link
Author

Hi Thanks for taking the time to respond, and update the package.

The following are the details you asked about:
version 0.1.1
Windows 10 64-bit
gams executable is in path

Here is a simple illustration with the code you provide in the examples. I modified as follows:

using JuMP,ReSHOP
#using Ipopt

m = Model(ReSHOP.Optimizer)
n = 30
l = -ones(n); l[1] = 0
u = ones(n)
@variable(m, l[i] <= x[i=1:n] <= u[i])
@NLexpression(m, f1, x[1])
@NLexpression(m, g, 1 + 9 * sum(x[j] ^ 2 for j = 2:n) / (n - 1))
@NLexpression(m, h, 1 - (f1 / g) ^ 2)
@NLexpression(m, f2, g * h)
#JuMP.set_start_value(x[1], 1)
#JuMP.set_start_value(x[2:n], zeros(n - 1))
@NLobjective(m, Min, f2)
@NLconstraint(m, log(exp(x[2])) <= u[2])
optimize!(m)

If I use Ipopt with this code. It runs really well and return an optimal solution. So I also wanted to take advantage of CONOPT4/3 and KNITRO that I have with my GAMS installation. I get the following error:

pointer_from_objref cannot be used on immutable objects

Stacktrace:
[1] error(::String) at .\error.jl:33
[2] pointer_from_objref at .\pointer.jl:146 [inlined]
[3] reshop_set_printops at C:\Users\KitchenComputer.julia\packages\ReSHOP\GLPwQ\src\reshop_utils.jl:17 [inlined]
[4] ReSHOP.Optimizer(; options::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\KitchenComputer.julia\packages\ReSHOP\GLPwQ\src\MOI_wrapper.jl:100
[5] ReSHOP.Optimizer() at C:\Users\KitchenComputer.julia\packages\ReSHOP\GLPwQ\src\MOI_wrapper.jl:100
[6] _instantiate_and_check(::Type{T} where T) at C:\Users\KitchenComputer.julia\packages\MathOptInterface\RmalA\src\instantiate.jl:56
[7] instantiate(::Type{T} where T; with_bridge_type::Type{Float64}, with_names::Bool) at C:\Users\KitchenComputer.julia\packages\MathOptInterface\RmalA\src\instantiate.jl:107
[8] set_optimizer(::Model, ::Type{T} where T; bridge_constraints::Bool) at C:\Users\KitchenComputer.julia\packages\JuMP\MnJQc\src\optimizer_interface.jl:66
[9] #Model#14 at C:\Users\KitchenComputer.julia\packages\JuMP\MnJQc\src\JuMP.jl:234 [inlined]
[10] Model(::Type{T} where T) at C:\Users\KitchenComputer.julia\packages\JuMP\MnJQc\src\JuMP.jl:233
[11] top-level scope at In[15]:2

@xhub
Copy link
Owner

xhub commented May 18, 2020

are you using Julia from the terminal or through another software?

I run your code on Windows 2012, both from the julia "terminal" and from Juno.
I will have a further look at it later. Basically it fails to set the interface for printing messages, which is not critical.

@Jovansam
Copy link
Author

I see. I tried in Atom-Juno and it worked. Great!

I use Julia with Jupyterlab (and Atom-Hydrogen) and there it seems to fail. This has happened to me with another great package (Complementarity.jl), which I now use only in Atom-Juno and Julia-vscode.

One thing, how do you choose which solver ReSHOP should direct the problem to, e.g., KNITOR vs CONOPT?

I am not a programmer. But if you want me to contribute in some capacity, say documentation, updating examples, for starters, I would be happy to.

@xhub
Copy link
Owner

xhub commented May 18, 2020

Thanks for the details. I will have a look at it on those setups. It should be too hard to support them as well.

So for choosing a solver, it is done at the Model creation. Any of the following works for me

m = Model(() -> ReSHOP.Optimizer(solver="knitro"))

or

m = Model(optimizer_with_attributes(ReSHOP.Optimizer, "solver" => "knitro"))

With older version of JuMP, the last option was given by

m = Model(with_optimizer(ReSHOP.Optimizer(solver="knitro")))

Replace knitro by conopt or any other solver name that your GAMS installation supports and it should work. Otherwise, let me know, and it will hopefully work soon. If you don't give the solver parameter, then the default solver, as set in the GAMS installation will be used.

Note that if you model becomes really large (thousands variables and constraints), or if you want to increase the speed, I would advice you to consider using the direct interface. It allows you to skip building an intermediate model representation in Julia.
On some simple benchmark, it reduces the memory footprint by 50%.
It is not 100% finish, but for most example it works. I am currently polishing the interface.
The Model creation in that case is

 m = direct_model(ReSHOP.Optimizer(solver="knitro"))

Thanks for your offer to help. I would definitively value a user perspective. Already reporting issues (and difficulties) is a valuable contribution. If you write examples, it's awesome.

Finally, if you use Complementarity.jl, you may want to know that JuMP recently got the ability to support complementarity contraints. ReSHOP should gain the ability so support that this week. Furthermore, I have my own package https://github.com/xhub/EMP.jl that aims at supporting complementarity problems, variational inequalities, equilibrium problem (Nash games). That's where my research interest are. It is not yet registered, and the documentation is not public. Currently it works only for JuMP 0.20, I may have to change the interface quite a bit to support JuMP 0.21, that's something that I definitively plan on doing soon. Let me know if you are interested.

@Jovansam
Copy link
Author

Definitely very helpful. Thanks. I completely had missed that Julia now supports complementarity. Nice! I will watch out for the EMP package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants