Changing the lower bound of a JuMp Model

i want to change the lower bound of a model from a zero array to take the value of the elements of another array here’s the function that i’m having

using JuMP
using Clp
function scan_maker(A)
    m = JuMP.Model(solver=ClpSolver(PrimalTolerance=1e-3, DualTolerance=1e-3, InfeasibleReturn=1, PresolveType=1))
   
    level = size(A, 2)
    v = zeros(Int, level)
    ub = zeros(Int, level)
    lb = zeros(Int, level)

    @variable(m, x[1:level])
    @constraint(m, con, A*x.>=0)

    function setc(c)
        for i = 1:size(A, 1)
            m.linconstr[i].lb = float(c[i])
        end
    end
end

now this function looks totally fine but when i type and run line by line for example if A=[1 2;1 1;2 2]and c=[1,2,1] the lower bound will always stay the same [0,0] it’s close from something like this :

function low(c)
    for i=1:size(A,1)
        m.linconstr[i].lb = float(c[i])
        println(lb)
    end
    
end
low([1,2,3])

and the output is this:
1.0
1.0
1.0
which is not true in this case, it shoud be 1.0 , 2.0 , 3.0
I don’t know what to do

Hi there. It looks like you’re using an old version of JuMP.

First, you should update to the most recent version: Introduction · JuMP

Then, you’re looking for the function set_normalized_rhs: Constraints · JuMP

The code you’re looking for is something like:

using JuMP
using Clp
model = Model(with_optimizer(Clp.Optimizer))
@variable(model, x[1:2])
A = rand(2, 2)
@constraint(model, con, A * x .>= 0)
set_normalized_rhs.(con, [1, 2])
2 Likes

but i guess Clp doesn’t support the last version of JuMP!!

what if i want to do it in JuMP 0.19

but i guess Clp doesn’t support the last version of JuMP!!

Clp does support the latest version of JuMP.

what if i want to do it in JuMP 0.19

You should really update to JuMP 0.20.

1 Like