-
-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from odow/fixmiqp
Fix handling of MIQP problem type. Fixes #115
- Loading branch information
Showing
3 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# QCP example | ||
# minimize x^2 | ||
# | ||
# s.t. x >= 0.1 | ||
# x ∈ {0, 1} | ||
# | ||
# solution: (0.1) objv = 0.01 | ||
|
||
using CPLEX | ||
using Base.Test | ||
|
||
# =========================================== | ||
|
||
m = CPLEX.CplexMathProgModel() | ||
CPLEX.loadproblem!(m, Array(Float64, (0,1)), [0.1], [Inf], [0], Float64[], Float64[], :Min) | ||
@test CPLEX.get_prob_type(m.inner) == :LP | ||
CPLEX.setquadobj!(m, [2]') | ||
@test CPLEX.get_prob_type(m.inner) == :QP | ||
CPLEX.optimize!(m) | ||
@test isapprox(CPLEX.getobjval(m), 0.5*0.1*2*0.1) | ||
|
||
# =========================================== | ||
|
||
m2 = CPLEX.CplexMathProgModel() | ||
CPLEX.loadproblem!(m2, Array(Float64, (0,1)), [0.1], [Inf], [0], Float64[], Float64[], :Min) | ||
@test CPLEX.get_prob_type(m2.inner) == :LP | ||
CPLEX.setvartype!(m2, [:Bin]) | ||
@test CPLEX.get_prob_type(m2.inner) == :MILP | ||
CPLEX.setquadobj!(m2, [2]') | ||
@test CPLEX.get_prob_type(m2.inner) == :MIQP | ||
CPLEX.optimize!(m2) | ||
@test isapprox(CPLEX.getobjval(m2), 0.5*1*2*1) | ||
|
||
# =========================================== | ||
|
||
m3 = CPLEX.CplexMathProgModel() | ||
CPLEX.loadproblem!(m3, Array(Float64, (0,1)), [0.1], [Inf], [0], Float64[], Float64[], :Min) | ||
@test CPLEX.get_prob_type(m3.inner) == :LP | ||
CPLEX.setquadobj!(m3, [2]') | ||
@test CPLEX.get_prob_type(m3.inner) == :QP | ||
CPLEX.setvartype!(m3, [:Bin]) | ||
@test CPLEX.get_prob_type(m3.inner) == :MIQP | ||
CPLEX.optimize!(m3) | ||
@test isapprox(CPLEX.getobjval(m3), 0.5*1*2*1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ tests = ["low_level_api", | |
"env", | ||
"sos", | ||
"problemtype", | ||
"miqcp", | ||
"mathprog" | ||
] | ||
|
||
|