You are on page 1of 3
2o23/3i10 ,£10:28, @3.ipynb -Colaboratory Spip install gurobipy?=10 import gurobipy as grb import numpy as np import math import matplotlib, pyplot as plt import scipy. stats Oi l=grb. Model (“Gas0il”) xI=n0il. addVar (vtype=mrb. GRB. CONTINUOUS, x2=n0il. addVar (vtype=grb. GRB. CONTINUOUS xS-m0il. addVar (vty Restricted license ~ for non-production use only ~ expires 2024-10-28 # Create capacity constraints 100i. addConstr ((9O%x1+70%x24+78%x3-91 4x4) <=90) 1041. addConstr ((Q0#x1+70%x2+78%x3-9 4x4) 2-85) # Create demand constraints OL, addConste ((2L0*x1+335*x2+280%x3+265%x4) >-270) nOiL, addCons tr ((210%x1+335"%2+280%x3 +265%x4) <=280) Oil, addConstr (x1 +x24x34x4==1) Oil, addConstr (x1>=0) m0 1. addConstr (x4>=0) m0i1, addConstr (x3>=0) 0:1. addConstr (x2>=0) # Objective: Maximize total revenue objectiveAir = 48¥x1+434x2+584x3+46%x4 nOiL. setOb jective (objectiveAir, grb. GRB. MINIMIZE) nOiL. update () Oil, optimize () [> Gurobi Optimizer version 10.0.1 build v10.0. 1re0 (Linux64) CPU model: Intel(R) Xeon(R) CPU @ 2. 206H2, instruction set [SSE2|AVX|AVK2] Thread count: 1 physical cores, 2 logical processors, using up to 2 threads Optimize a model with 17 rows, 4 columns and 44 nonzeros Coefficient statistics Matrix range [1e#00, 30402] Objective range [4e+01, 6e+01] Bounds range {0e+00, 02100) RHS range {le+00, 30102) Iteration Objective Primal Inf, Dual Inf. Time -ntps:ifeolab rosearch google. com/driva/tIDBHAZ|TB.UaNAByZd3L_GKZWRIK6_KR ?authuser=2iscrolTo=Cgzbx'KeSKUMEprintModo=tue 18 2o2a/3i10 te £10:25, Q3.ipynb - Colboratory 0 4,42718890+01 4, 2228740-01 0, 0000000+00 Os 2 4,5326531e#01 0, 000000e+00 0, 0000000+00 os Solved in 2 iterations and 0.01 seconds (0.00 work units) Optimal objective 4, 5326530610101 print (n0il. Status rb. GRB. OPTIMAL) print (mOil. display ()) True Minimize 48.0 01 + 43.0 02 + 58.0 03 » 46,0 04 Subject To RO: 90.0 O1 + 70,0 02 + 78.0 03 + 91.0 04 Ri: 90.0 O1 + 70.0 02 + 78.0 03 + 91.0 04 R2: 210.0 01 + 335.0 02 + 280.0 03 + 265.0 04 R3: 210.0 01 + 335.0 02 + 280.0 03 + 265.0 04 Rd: OL = 0 R5: OL >= 0 R6: 03 >= 0 R7: 02 >= 0 RS: 90,0 01 + 70,0 02 + 78,0 03 + 91.0 04 < 90 R9: 90.0 Ol + 70.0 02 + 78.0 03 + 91.0 04 >= 85 RIO: 210.0 O1 + 335.0 02 1 280.0 03 + 265,0 04 >= 270 RIL: 210,0 O1 + 335.0 02 + 280,0 03 + 265,0 04 <= 280 R12: 01 + 02 + 03 + OF = 1 R13: 01 >= 0 R14: 04 >= 0 RIS RIB: 02 >= 0 None BURR print (“Optimal gasoline blen:”) print (“Oil_l: "xD printCoil2: ", x2) printCoil3: —* x8) print(Oila: *, x4) optobj-m0il. get0b jective) print ("Total Cost: $”, optobj. getValue()) Optimal gasoline blen: Oil: — OiL_2: Oil_3: — O14: Total Cost: $ 45. 3265306122449 -ntps:ifeolab rosearch google. com/driva/tIDBHAZ|TB.UaNAByZd3L_GKZWRIK6_KR ?authuser=2iscrolTo=Cgzbx'KeSKUMEprintModo=tue 28 2o2a/3i10 te £10:25, Q3ipynb- Colaboratory v Of SepeRSRT: BeL10:25 ex hitpseola research, google. comidrvaliDBHAZ/TEJUaNAB)Za31_GKZWXIXE_KR?authus 33

You might also like