Thanks so much for the help! = 8, name = 'c1') c2 = opt_mod.addConstr(2*x + y >= 10, name = 'c2') c3 = opt_mod.addConstr(x + 4*y >= 11, name = 'c3') #6 opt_mod.optimize() #solve the model opt_mod.write("linear_model.lp") #output the LP file of the model #7 print('Objective Function Value: %f' % opt_mod.objVal) #Get values of the decision variables for v in opt_mod.getVars(): print('%s: %g' % (v.varName, v.x))
Hi, I have an optimisation model in a "for loop"using Python and Gurobi. For each iteration I need to record the decision variables and use them as an input of next "for loop". I was wondering if you advise me how I can record the decision variables in each loop. Thanks
Thanks so much for the help! = 8, name = 'c1')
c2 = opt_mod.addConstr(2*x + y >= 10, name = 'c2')
c3 = opt_mod.addConstr(x + 4*y >= 11, name = 'c3')
#6
opt_mod.optimize() #solve the model
opt_mod.write("linear_model.lp") #output the LP file of the model
#7
print('Objective Function Value: %f' % opt_mod.objVal)
#Get values of the decision variables
for v in opt_mod.getVars():
print('%s: %g' % (v.varName, v.x))
Thank you, first time using gurobi, thanks once again.
It's a useful video, thanks.
thanks lad, this saved me a lot of research work
Thanks!
Hi,
I have an optimisation model in a "for loop"using Python and Gurobi. For each iteration I need to record the decision variables and use them as an input of next "for loop".
I was wondering if you advise me how I can record the decision variables in each loop.
Thanks
Hi Zahra,
You can store them in a list and then use that list as an input in your loop.
Best,
The Team
Can u also provide the repository for the source code, please
0:34 - What is linear programming
1:48 - A small example of linear model
3:54 - Solving the linear model in Python