Created
September 25, 2019 12:04
-
-
Save rschwarz/dbdb7b4a506c38aabddd91dd04ac26c0 to your computer and use it in GitHub Desktop.
Testing SCIP.jl with JuMP.jl in direct mode.
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
julia> test() | |
ERROR: In `@constraint(model, ind, ind_fun in ind_set)`: unable to add the constraint because we don't recognize MathOptInterface.VectorAffineFunction{Float64}(MathOptInterface.VectorAffineTerm{Float64}[VectorAffineTerm{Float64}(1, ScalarAffineTerm{Float64}(1.0, VariableIndex(3))), VectorAffineTerm{Float64}(2, ScalarAffineTerm{Float64}(0.2, VariableIndex(1))), VectorAffineTerm{Float64}(2, ScalarAffineTerm{Float64}(1.0, VariableIndex(2)))], [0.0, 0.0]) as a valid JuMP function. | |
Stacktrace: | |
[1] error(::String, ::String) at ./error.jl:42 | |
[2] _macro_error(::Symbol, ::Array{Any,1}, ::String) at /home/rs/.julia/packages/JuMP/iGamg/src/macros.jl:1091 | |
[3] (::getfield(JuMP, Symbol("#_error#55")){Symbol})(::String) at /home/rs/.julia/packages/JuMP/iGamg/src/macros.jl:565 | |
[4] build_constraint(::getfield(JuMP, Symbol("#_error#55")){Symbol}, ::MathOptInterface.VectorAffineFunction{Float64}, ::MathOptInterface.IndicatorSet{ACTIVATE_ON_ONE::ActivationCondition = 1,MathOptInterface.LessThan{Float64}}) at /home/rs/.julia/packages/JuMP/iGamg/src/macros.jl:462 | |
[5] macro expansion at /home/rs/.julia/packages/JuMP/iGamg/src/macros.jl:619 [inlined] | |
[6] test() at /home/rs/scratch.jl:27 | |
[7] top-level scope at none:0 |
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
using JuMP | |
using SCIP | |
function test() | |
model = direct_model(SCIP.Optimizer()) | |
@variable(model, x >= 0) | |
@variable(model, y) | |
@variable(model, z) | |
@constraint(model, linear, x + y == z) | |
@constraint(model, quadratic, x^2 + y^2 <= z) | |
@constraint(model, soc, [x, y, z] in SecondOrderCone()) | |
@constraint(model, sos1, [x, y, z] in JuMP.MOI.SOS1([1.0, 2.0, 3.0])) | |
@constraint(model, sos2, [x, y, z] in JuMP.MOI.SOS2([1.0, 2.0, 3.0])) | |
@constraint(model, abspow, [z, x] in SCIP.AbsolutePowerSet(2.0)) | |
@NLconstraint(model, nl, x*y/z - x^z == 1) | |
# z == 1 ==> 0.2x + y ≤ 9 | |
ind_fun = JuMP.MOI.VectorAffineFunction( | |
[JuMP.MOI.VectorAffineTerm(1, JuMP.MOI.ScalarAffineTerm(1.0, z.index)), | |
JuMP.MOI.VectorAffineTerm(2, JuMP.MOI.ScalarAffineTerm(0.2, x.index)), | |
JuMP.MOI.VectorAffineTerm(2, JuMP.MOI.ScalarAffineTerm(1.0, y.index))], | |
[0.0, 0.0]) | |
ind_set = JuMP.MOI.IndicatorSet{JuMP.MOI.ACTIVATE_ON_ONE}(JuMP.MOI.LessThan(9.0)) | |
@constraint(model, ind, ind_fun in ind_set) | |
@show linear quadratic soc sos1 sos2 abspow nl ind | |
return model | |
end |
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
(scip) pkg> st | |
Status `~/.julia/environments/scip/Project.toml` | |
[fa961155] CEnum v0.1.2 | |
[40e3b903] Clang v0.9.0 | |
[4076af6c] JuMP v0.20.0 | |
[ee0a3090] MINLPTests v0.4.0 [`~/.julia/dev/MINLPTests`] | |
[b8f27783] MathOptInterface v0.9.3 | |
[82193955] SCIP v0.9.1 [`~/.julia/dev/SCIP`] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment