A question about my code


is that right?
but Error when entering data
it shows
Obj([10 1 -1;2 6 1],[10 1 -1;2 6 1],20,[-2; -11])
ERROR: UndefVarError: X not defined
Stacktrace:
[1] macro expansion at C:\Users\dell.juliapro\JuliaPro_v1.3.1-2\packages\JuMP\MsUSY\src\macros.jl:189 [inlined]
[2] Obj(::Array{Int64,2}, ::Array{Int64,2}, ::Int64, ::Array{Int64,1}) at D:\Julia\Julia-1.2.0\Obj.jl:7
[3] top-level scope at none:0
thank you!

You are more likely to get help if you post the code in a way that other users can copy and paste into their own terminal.

3 Likes
using JuMP
using SCIP
function Obj(SC,SB,B,C)
text = Model( with_optimizer(SCIP.Optimizer))
@variable(text,X[1:2],0<=X<=100,Int)
@objective(text,Min,C'*X+B)
@constraint(text,SC*X'.+SB<=0)
optimize!(text)
end

ok,i will,thanks

I think this should be (untested):

@variable(text, 0 <= X[1:2] <= 100, Int)

Also, in your constraint, you should probably use .<= since you have a vector on the left-hand side, right?