I have an optimization problem where i want to change the RHS of a set of constraints and solve the model each time.
The RHS Demand_specific is the input to the model. I want to test the model for different fluctuations in demand values, so i am changing the demand matrix iteratively.
using JuMP, Gurobi for t in 1:n_echelons for g in 1:n_customers for k in 1:n_customers for p in 1:n_products @constraint(IMTLP, Demandsconst, Direct_shipping[k,g,p,t]+sum(Endhaul_shipping[j,g,k,p,t] for j in 1:n_hubs)>=Demand_specific[g,k,p,t]) end end end end OptimalCosts = zeros(n_instances) for i in 1:n_instances JuMP.setRHS(Demandsconst, (2i/n_instances)*Demand_specific) status = solve(IMTLP) z = getobjectivevalue(IMTLP) OptimalCosts[i] = z end
I am getting the following warning:
Warning: A variable or constraint named Demandsconst is already attached to this model. If creating constraints programmatically, use the anonymous constraint syntax con = @constraint(m, …).