I’m using JuMP v1.4.0 and I want to generate an LP format file of the following model, but it doesn’t work, the file is not generated, and I don’t know why. Thanks in advance.
using JuMP
using Gurobi
model = Model(Gurobi.Optimizer)
@variable (model, x >= 0)
@variable (model, 0 <= y <= 3)
@objective (model, Min, 12x + 20y)
@constraint (model, c1, 6x + 8y >= 100)
@constraint (model, c2, 7x + 12y >= 120)
optimize!(model)
write_to_file(model, “modelplus.lp”)
@show termination_status(model)
odow
November 20, 2022, 6:09pm
2
the file is not generated
The file is generated, it just writes to the directory returned by pwd()
. This is likely not where you expected it to be?
You can always give the full path, for example, on my machine it would be write_to_file(model, "/Users/Oscar/Desktop/modelplus.lp")
.
It works, thank you so much. BTW, the NLP is not supported by write_to_file(), is there any way to generate files like this to be used in other platforms?
odow
November 21, 2022, 1:19am
4
the NLP is not supported by write_to_file
You can use the .nl
file format: write_to_file("model.nl")
It generates a file by using the method, but I’ve no idea what the model in the .nl file means. It looks like the following:
g3 1 1 0
564 695 1 0 500 0
426 1
0 0
484 0 0
0 0 0 1
0 0 0 0 0
5632 22
0 0
0 0 0 0 0
C0
o1
o1
v36
o2
n1.5
o0
n1
o2
n0.15
o5
o3
v0
…
I don’t know if the file could be used in my work, but thank you anyway.
odow
November 21, 2022, 7:14am
6
Its a standard file format nl (format) - Wikipedia , albeit not very user friendly one.
What do you want to do with the file? You can read it using read_from_file
.