optimizationjuliaconstraintsjulia-jump

Limit values ​of a variable in Julia JUMP


How can I write a constraint that indicates that my variable can only take values ​​that are multiples of 35?


Solution

  • using JuMP, Gurobi
    m = Model(Gurobi.Optimizer)
    @variable(m, x>=0, Int)
    y = 35x
    

    Now you can use y as any other variable in your optimization model.

    If you want to have such constraint on the value of the objective (as the link that points to the deleted question) you could do (I reuse x from the previous example):

    @variable(m,z1)
    @variable(m,z2)
    
    ob = 3z1 + 2z2
    
    @constraint(m, ob == 35x)
    @objective(m, Max, ob)