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

Differences between 0.7.0 and 0.8.4 #124

Closed
s3baki opened this issue Oct 8, 2021 · 2 comments
Closed

Differences between 0.7.0 and 0.8.4 #124

s3baki opened this issue Oct 8, 2021 · 2 comments

Comments

@s3baki
Copy link

s3baki commented Oct 8, 2021

I inadvertently closed the previous item while attaching files.

@s3baki
Copy link
Author

s3baki commented Oct 8, 2021

How I use the code in 0.7.0:

using MathProgBase # version v0.7.8
using Clp # version v0.7.0

linprog(obj, a, '=', rhs, lb, ub, ClpSolver(MaximumIterations = maxiter, MaximumSeconds = maxtime, SolveType = solvetype))

@s3baki
Copy link
Author

s3baki commented Oct 8, 2021

How I use the code in 0.8.4

using JuMP # version 0.21.10
using Clp # version 0.8.4

function decision_solver(
obj::Vector{Float64},
a::Matrix{Float64},
rhs::Vector{Float64},
ub::Vector{Float64},
lb::Vector{Float64},
maxtime::Int64,
maxiter::Int64)
model = Model(Clp.Optimizer);
@variable(model, lb[i] <= x[i=1:length(lb)] <= ub[i]);
@objective(model, Min, obj'x);
# Depending on the sense vector, you may need to split it into <= and >= constraints too
@constraint(model, a * x .== rhs);
JuMP.set_optimizer_attribute(model, "LogLevel", 0)
JuMP.set_optimizer_attribute(model, "MaximumIterations", maxiter)
optimize!(model);
status = Symbol(lowercase(string(termination_status(model))))
if status in [:infeasible, :dual_infeasible]
JuMP.set_optimizer_attribute(model, "SolveType", 1)
optimize!(model);
status = Symbol(lowercase(string(termination_status(model))))
end
if status != :optimal
return (status, 0.0, Vector{Float64}())
end
sol = value.(x)
objval = objective_value(model)
return (status, objval, sol)
end

@odow odow closed this as completed Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants