Professional Documents
Culture Documents
1.3. Consider The Bond-Portfolio Problem Formulated in Section 1.3. Reformulate The Problem
1.3. Consider The Bond-Portfolio Problem Formulated in Section 1.3. Reformulate The Problem
1.3. Consider The Bond-Portfolio Problem Formulated in Section 1.3. Reformulate The Problem
try:
# Create a new model
m = Model('Portfolio Selection')
# Set object
m.setObjective(0.043*x + 0.0022*y, GRB.MAXIMIZE)
m.optimize()
for v in m.getVars():
print v.varName, v.x
except GurobiError:
print 'Error Report'
OUTPUT:
1.9
python code:
try:
# Create a new model
m = Model('Portfolio Selection')
# Set object
m.setObjective(3*x1 + 9*x2 + 25*x3, GRB.MAXIMIZE)
m.optimize()
for v in m.getVars():
print v.varName, v.x
except GurobiError:
print 'Error Report'
OUTPUT:
Optimize a model with 3 rows, 3 columns and 9 nonzeros
Coefficient statistics:
Matrix range [1e-01, 7e-01]
Objective range [3e+00, 2e+01]
Bounds range [2e+02, 4e+02]
RHS range [2e+02, 4e+02]
Presolve removed 3 rows and 3 columns
Presolve time: 0.00s
Presolve: All rows and columns removed
Iteration Objective Primal Inf. Dual Inf. Time
0 8.2916667e+03 0.000000e+00 0.000000e+00 0s