Oil refinery production optimization#
Description: In this document, we present an enhanced approach to oil refining optimization for improved decision-making.
This notebook showcases how to model a complex model with AMPL, solving it with the open-source solver Highs.
Tags: Oil production, Production optimization, Profitability, Refinery, mip, highs, industry, json, spreadsheet, excel
Notebook author: Mikhail Riabtsev <mail@solverytic.com>
1. Introduction#
Context and Significance#
The petroleum refining industry is one of the most crucial and intricate sectors in the global economy. It plays a pivotal role in converting crude oil into an array of valuable products such as gasoline, diesel, jet fuel, lubricants, and petrochemicals, which are indispensable to modern life and industrial processes. The industry’s complexity arises from the need to manage and optimize a series of interconnected processes, each with its own set of constraints and requirements. Furthermore, the industry operates in a highly volatile environment, influenced by fluctuating crude oil prices, stringent environmental regulations, technological advancements, and dynamic market demands.
Effective decision-making in this context is paramount. Refinery managers must balance multiple objectives: maximizing output and profitability, minimizing costs, ensuring compliance with environmental standards, and maintaining operational efficiency. These challenges underscore the necessity for sophisticated optimization models that can integrate various facets of refinery operations and provide strategic insights.
Problem Statement#
The primary goal of this project is to develop a comprehensive optimization model for a petroleum refinery. This model aims to maximize the refinery’s total profit over a specified planning horizon. To achieve this, the model will encompass various stages of the refining process, including distillation, reforming, cracking, and lubricating. Additionally, it will incorporate elements such as production planning, blending operations, inventory management, financial planning, pollutant emission controls, and maintenance scheduling.
The proposed model will serve as a decision-support tool, guiding refinery managers in:
Production Planning: Optimizing the production levels of intermediate and final products to align with market demand and operational capacities.
Blending Operations: Determining optimal blending ratios to meet product quality specifications while maximizing efficiency.
Inventory Management: Efficiently managing the storage and movement of crude oil and intermediate products to minimize holding costs and avoid shortages or surpluses.
Market and Demand Management: Adjusting production and blending strategies in response to market demand and price fluctuations.
Financial Planning: Ensuring effective management of cash flows, loans, and financial balances to support ongoing operations and investments.
Regulatory Compliance: Adhering to environmental regulations by managing pollutant emissions and other environmental impacts.
Maintenance Scheduling: Planning for equipment maintenance and plant shutdowns to minimize downtime and associated costs.
Scope and Objectives#
The scope of this optimization model is to provide a holistic framework that integrates all aspects of refinery operations. The specific objectives include:
Decision Variables: Identifying key variables such as production levels, blending ratios, inventory levels, cash flows, loan amounts, and binary variables for plant and equipment status.
Constraints: Incorporating constraints related to operational capacities, storage limits, delivery schedules, pollutant emission limits, financial balances, loan limits, market demand, product quality standards, and maintenance requirements.
Objective Function: Developing a total profit maximization function that accounts for revenues from product sales, costs of production and blending, inventory holding costs, costs of disposal of production waste, costs of planned plant shutdown,loan interest expenses, and maintenance costs. By achieving these objectives, the model will provide actionable insights and recommendations for optimizing refinery operations, thereby enhancing profitability and sustainability.
In this example, we’ll demonstrate how to use mathematical optimization to optimize the output of a refinery. You’ll learn how to generate an optimal production plan that maximizes total profit, while taking into account production capacity and other restrictions.
Expected Outcomes#
The successful implementation of this optimization model is anticipated to deliver several key benefits:
Enhanced Profitability: Optimizing production, blending, and financial decisions will maximize profit margins and overall financial performance.
Operational Efficiency: Improved planning and scheduling will enhance the efficiency of production processes and maintenance activities.
Market Responsiveness: The model’s ability to incorporate demand elasticity will allow the refinery to adapt swiftly to changes in market conditions.
Regulatory Compliance: Ensuring adherence to environmental standards will help avoid legal penalties and enhance the refinery’s reputation.
Strategic Financial Management: Effective management of cash flows and loans will ensure financial stability and reduce the cost of capital.
Conclusion#
In conclusion, the development and implementation of this optimization model will provide a powerful tool for refinery management. It will facilitate informed decision-making, driving long-term success in a competitive and ever-changing industry. By addressing the multifaceted challenges of refinery operations, this model will help achieve a balance between profitability, efficiency, and sustainability, ensuring the refinery’s resilience and growth in the face of future challenges.
The operating pattern of an oil refinery depends on its specialization (type of equipment installed) and the type(s) of oil processed. In this example, we will use the part of the general scheme of oil refining.
2. Problem Description#
Stage 1: Distillation#
An oil refinery purchases two types of crude oil (Crude1
and Crude2
). The cost of purchased oil changes over time periods, $/barrel:
Oil type |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
80 |
80 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
|
85 |
86 |
87 |
88 |
89 |
90 |
90 |
90 |
90 |
91 |
91 |
91 |
The terms of the concluded contracts include restrictions on the maximum volume of oil supplied in each period, barrels:
Oil type |
Max |
---|---|
|
40000 |
|
25000 |
Purchased crude oil is distilled into several fractions:
Light Naphta
(with an octane number of 90)Medium Naphta
(with an octane number of 80)Heavy Naphta
(with an octane number of 70)Light Oil
(with an vapor pressur of 1)Heavy Oil
(with an vapor pressur of 0.6)Residuum
(with an vapor pressur of 0.05)
One barrel of crude separates into the following fractions:
Operating mode |
Oil type |
|
|
|
|
|
|
---|---|---|---|---|---|---|---|
|
|
0.1 |
0.2 |
0.2 |
0.12 |
0.2 |
0.13 |
|
|
0.15 |
0.25 |
0.18 |
0.08 |
0.19 |
0.12 |
|
|
0.12 |
0.19 |
0.19 |
0.13 |
0.19 |
0.13 |
|
|
0.14 |
0.24 |
0.19 |
0.09 |
0.18 |
0.13 |
The distillation process operates under different modes (e.g., D1
, D2
), each with its own capacity, cost, setup characteristics, pollution level and the cost of waste disposal:
Operating mode |
Maximum productivity, barrels/period |
Duration of the equipment setup period |
Equipment reconfiguring cost, $ |
---|---|---|---|
|
45 000 |
50 000 |
0.5 |
|
47 000 |
70 000 |
0.5 |
*The costs of reconfiguring equipment are taken into account only if reconfiguration is needed.
The cost of distilling 1 barrel of crude oil and the cost of disposal of process residues are:
Operating mode |
Oil type |
Cost of Distillation, per barrel |
Residue disposal cost, per barrel |
---|---|---|---|
|
|
18 |
2 |
|
|
15 |
3 |
|
|
17 |
1.5 |
|
|
16 |
2.2 |
The process of recycling the residues of the distillation process is accompanied by the release of the following amount of harmful substances:
Operating mode |
Oil type |
|
|
---|---|---|---|
|
|
100 |
120 |
|
|
105 |
116 |
|
|
99 |
115 |
|
|
108 |
111 |
The refinery then uses some amount of the distillation products as inputs for further processing in Reforming, Cracking, and Lubricating processes.
Stage 2:#
2.1. Reforning#
This process converts specific distillation products (Light Naphta
,Medium Naphta
, Heavy Naphta
) into reforming products such as Reformed gasoline
(with an octane number of 115).
From 1 barrel of distillation products, the following amounts of reformed gasoline can be obtained:
Operating mode |
Distillation product |
|
---|---|---|
|
|
0.6 |
|
|
0.52 |
|
|
0.45 |
|
|
0.6 |
|
|
0.52 |
|
|
0.48 |
The reforming installation can operate in different modes (e.g., R1
, R2
), each with its own capacity and cost.
Operating mode |
Maximum productivity, barrels/period |
Duration of the equipment setup period |
Equipment reconfiguring cost, $ |
---|---|---|---|
|
10 000 |
0.5 |
80 000 |
|
12 000 |
0.6 |
90 000 |
*The costs of reconfiguring equipment are taken into account only if reconfiguration is needed.
The cost of reforming 1 barrel of distilling products and the cost of disposal of process residues are:
Operating mode |
Distillation product |
Cost of Reforming, per barrel |
Residue disposal cost, per barrel |
---|---|---|---|
|
|
20 |
2 |
|
|
26 |
1.8 |
|
|
28 |
2.2 |
|
|
22 |
2 |
|
|
24 |
3 |
|
|
26 |
1.3 |
The process of recycling the residues of the reforming process is accompanied by the release of the following amount of harmful substances:
Operating mode |
Distillation product |
|
|
---|---|---|---|
|
|
60 |
180 |
|
|
70 |
140 |
|
|
72 |
115 |
|
|
65 |
180 |
|
|
40 |
150 |
|
|
70 |
118 |
2.2. Cracking#
This process converts specific distillation products (Light Oil
,Heavy Oil
) into cracking products such as Cracked oil
(with an vapor pressur of 1.5) and Cracked gasoline
(with an octane number of 105).
From 1 barrel of distillation products the following amounts of cracked products can be obtained:
Operating mode |
Distillation product |
|
|
---|---|---|---|
|
|
0.68 |
0.28 |
|
|
0.75 |
0.2 |
|
|
0.6 |
0.34 |
|
|
0.52 |
0.25 |
The cracking installation can operate in different modes (e.g., CR1
, CR2
), each with its own capacity and cost.
Operating mode |
Maximum productivity, barrels/period |
Duration of the equipment setup period |
Equipment reconfiguring cost, $ |
---|---|---|---|
|
8 000 |
0.3 |
25 000 |
|
9 000 |
0.2 |
36 300 |
*The costs of reconfiguring equipment are taken into account only if reconfiguration is needed.
The cost of cracking 1 barrel of distilling products and the cost of disposal of process residues are:
Operating mode |
Distillation product |
Cost of Cracking, per barrel |
Residue disposal cost, per barrel |
---|---|---|---|
|
|
20 |
1 |
|
|
22 |
1.2 |
|
|
21 |
1.36 |
|
|
18 |
1.05 |
The process of recycling the residues of the cracking process is accompanied by the release of the following amount of harmful substances:
Operating mode |
Distillation product |
|
|
---|---|---|---|
|
|
100 |
200 |
|
|
150 |
250 |
|
|
120 |
180 |
|
|
150 |
240 |
2.3. Lubricating#
This process converts specific distillation products (Residuum
) into Lube Oil
.
From 1 barrel of distillation products the following amounts of lubrication products can be obtained:
Operating mode |
Distillation product |
|
---|---|---|
|
|
0.5 |
|
|
0.6 |
The lubricating installation can operate in different modes (e.g., L1
, L2
), each with its own capacity and cost.
Operating mode |
Maximum productivity, barrels/period |
Duration of the equipment setup period |
Equipment reconfiguring cost, per barrel |
---|---|---|---|
|
500 |
0.2 |
5 000 |
|
1 000 |
0.1 |
8 000 |
*The costs of reconfiguring equipment are taken into account only if reconfiguration is needed.
The cost of lubricating 1 barrel of distilling products and the cost of disposal of process residues are:
Operating mode |
Distillation product |
Cost of Lubricating, per barrel |
Residue disposal cost, per barrel |
---|---|---|---|
|
|
21 |
1.2 |
|
|
22 |
1.4 |
The process of recycling the residues of the lubricating process is accompanied by the release of the following amount of harmful substances:
Operating mode |
Distillation product |
|
|
---|---|---|---|
|
|
60 |
180 |
|
|
70 |
140 |
It is advisable to produce Lube Oil
in a volume of no more than 1000.
Stage 3: Blending#
All intermediate components obtained at the stages Distillation, Reforming, Cracking, Lubricating can be mixed to obtain the final petroleum products:
3.1. Regular and premium gasoline
Can be made by blending Light Naphta
, Medium Naphta
, Heavy Naphta
, Reformed gasoline
and Cracked gasoline
. The only requirement is that Regular gasoline
must have an octane of at least 84 and Premium gasoline
must have an octane number of at least 94. It is assumed that octane numbers blend linearly by volume.
Premium gasoline
production must be at least 40% of Regular gasoline
production.
3.2. Jet Fuel
Can be made by blending Light Oil
, Heavy Oil
, Residuum
, and Cracked Oil
. Jet fuel
must have a vapor pressure that does not exceed 1.0. It is assumed that vapor pressures blend linearly by volume.
3.3. Fuel Oil
To produce Fuel Oil
, it is necessary to mix Light Oil
, Cracked Oil
, Heavy Oil
and Residuum
in the ratio of 10:4:3:1.
3.4. Lube Oil
Was produced at the Stage 2.3. Lubricating.
The cost of the process of blending various petroleum products has the following cost:
Product |
Cost of blending, $/barrel |
---|---|
|
2 |
|
1.9 |
|
2.2 |
|
2 |
|
2.4 |
Stage 4: Storage#
Finished petroleum products are delivered to fuel storage facilities. Storage capacity, storage cost, loss percentage during storage are presented below:
Product |
Storage Capacity, barrels |
Storage Cost, $/barrel |
Storage Waste, % |
---|---|---|---|
|
50 000 |
3 |
0.3 |
|
50 000 |
5 |
0.2 |
|
30 000 |
7 |
0.1 |
|
10 000 |
2 |
0.05 |
|
4 500 |
4 |
0.05 |
The cost of delivery petroleum products to gas stations is:
Product |
|
---|---|
|
2 |
|
2 |
|
3 |
|
2 |
|
4 |
Factory restrictions#
Operating an oil refinery involves fixed costs of 300,000 each period. In addition, during the periods under review, a planned technical shutdown of the plant lasting 1 period is required. During the planned shutdown, the plant can only release finished petroleum products to customers but not produce new ones. The cost of various technical works during the suspension is 100,000. During the technological shutdown, all fixed costs of the plant continue to apply. At the beginning of the period under review, the plant’s current account contains 2 million.
Demand#
Historical data on demand for petroleum products demonstrates seasonal variations in demand:
Product |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
‘Premium Gasoline’ |
4 500 |
4 500 |
4 500 |
4 500 |
5 000 |
7 000 |
7 500 |
7 000 |
6 000 |
5 000 |
4 500 |
5 000 |
‘Regular Gasoline’ |
8 500 |
8 500 |
8 500 |
8 800 |
9 200 |
13 500 |
14 000 |
13 500 |
12 000 |
10 000 |
9 000 |
10 000 |
‘Jet Fuel’ |
7 000 |
7 000 |
7 000 |
9 000 |
12 000 |
10 000 |
9 000 |
8 000 |
8 000 |
9 000 |
7 000 |
7 000 |
‘Fuel Oil’ |
4 000 |
3 800 |
3 800 |
3 800 |
2 900 |
2 500 |
2 500 |
2 800 |
3 300 |
3 400 |
3 500 |
3 600 |
‘Lube Oil’ |
500 |
500 |
700 |
700 |
700 |
500 |
400 |
500 |
600 |
700 |
700 |
700 |
During the periods under review, the following changes in the average market price are expected:
Average market price: |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
‘Premium Gasoline’ |
162 |
165 |
165 |
165 |
165 |
165 |
165 |
167 |
168 |
168 |
167 |
165 |
‘Regular Gasoline’ |
126 |
126 |
127 |
127 |
128 |
128 |
129 |
129 |
129 |
129 |
130 |
130 |
‘Jet Fuel’ |
115 |
115 |
115 |
115 |
115 |
116 |
116 |
116 |
117 |
117 |
118 |
118 |
‘Fuel Oil’ |
154 |
154 |
154 |
155 |
155 |
155 |
155 |
156 |
156 |
156 |
155 |
155 |
‘Lube Oil’ |
176 |
176 |
177 |
177 |
177 |
178 |
178 |
178 |
178 |
178 |
177 |
178 |
The following price elasticities apply for all petroleum products:
Relative price change* |
Relative change in demand |
---|---|
+6% |
-20% |
+4% |
-12% |
+2% |
-5% |
-2% |
+2% |
-4% |
+5% |
-6% |
+9% |
This means that when the price of petroleum products increases by 6% relative to the market average, demand decreases by 20% relative to average historical data.
Finance#
To financially evaluate all transactions, use a discount rate of 5%. The purchase of raw materials and the sale of finished petroleum products assumes the availability of the full amount of necessary payments. In case of a shortage of working capital, the oil refinery has the opportunity to obtain bank loans every period on the following conditions:
Name |
Term |
Interest rate |
Maximum amount, $ |
---|---|---|---|
I |
1 |
6.5 |
10 000 000 |
The loan received in the previous period and the interest accrued on it must be paid in the current period.
Objective#
How should the operations of the refinery be planned in order to maximize total profit?
Let’s start by downloading the necessary extensions and libraries
# Install dependencies
%pip install -q amplpy pandas openpyxl
import pandas as pd
import numpy as np
import json
# Google Colab & Kaggle integration
from amplpy import AMPL, ampl_notebook
ampl = ampl_notebook(
modules=["highs"], # modules to install
license_uuid="default", # license to use
) # instantiate AMPL object and register magics
3. Formulation of the model#
%%writefile oil_refining.mod
reset;
### SETS
set CRUD ; # Types of crude oil (Crude1, Crude2)
set DIST ; # Distillation products
set REF ; # Reforming products
set CRACK ; # Cracking products
set LUBR ; # Lubricating products
set PROD ; # Final products
set STAT ; # Delivery stations
set D_MODE ; # Operating modes of the equipment of the Distillation installation
set R_MODE ; # Operating modes of the equipment of the Reforming installation
set CR_MODE ; # Operating modes of the equipment of the Cracking installation
set L_MODE ; # Operating modes of the equipment of the Lubrication process
set POLLUT ; # Types of pollutants
set DISTILLATION within {D_MODE, CRUD, DIST} ; # Pairs of the Distillation process
set REFORMING within {R_MODE, DIST, REF} ; # Pairs of the Reforming process
set DIST_R := setof{(m,d,r) in REFORMING}(d) ; # List of included components
set CRACKING within {CR_MODE, DIST, CRACK} ; # Pairs of the Cracking process
set DIST_CR := setof{(m,d,cr) in CRACKING}(d) ; # List of included components
set LUBRICATING within {L_MODE, DIST, LUBR} ; # Pairs of the Lubricating process
set DIST_L := setof{(m,d,l) in LUBRICATING}(d) ; # List of included components
set BLENDING within # Pairs of Intermediate and final products involved in blending
{DIST union REF union CRACK union LUBR, PROD} ;
set INTERMED:= setof{(i,j) in BLENDING}i ; # Set of Intermediate products before blending
### PARAMETERS
param nPeriod >= 0 ; # Number of weeks in the planning period
param nPeriodByYear >= 0 ; # Number of nPeriods in the Year
## Crude oil
param crude_Min{CRUD} = 0 ; # Minimum supply limits for each crude oil type
param crude_Max_capacity{c in CRUD} >= crude_Min[c] ; # Maximum supply limits for each crude oil type
param crude_Cost{CRUD, 1..nPeriod} >= 0 ; # Cost of crude oil per week
## Distillation
param distill_Yield{DISTILLATION} >= 0 ; # Yield of products
param distill_Pollute{D_MODE, CRUD, POLLUT} ; # Pollutant emissions
param distill_Cost{D_MODE, CRUD} >= 0 ; # Cost of process
param distill_Waste_Cost{D_MODE, CRUD} >= 0 ; # Residue disposal cost
param distill_Equipment_Setup_Period{D_MODE} >= 0 ; # Equipment setup period
param distill_Equipment_Setup_Cost{D_MODE} >= 0 ; # Equipment setup cost
param distill_Max_capacity{D_MODE} >= 0 ; # Maximum capacity
## Reforming
param reform_Yield{REFORMING} >= 0 ; # Yield of products
param reform_Pollute{R_MODE, DIST_R, POLLUT} ; # Pollutant emissions
param reform_Cost{R_MODE, DIST_R} >= 0 ; # Cost of process
param reform_Waste_Cost{R_MODE, DIST_R} >= 0 ; # Residue disposal cost
param reform_Max_capacity{R_MODE} >= 0 ; # Maximum capacity
param reform_Equipment_Setup_Period{R_MODE} >= 0 ; # Equipment setup period
param reform_Equipment_Setup_Cost{R_MODE} >= 0 ;# Equipment setup cost
## Cracking
param crack_Yield{CRACKING} >= 0 ; # Yield of products
param crack_Pollute{CR_MODE, DIST_CR, POLLUT} ; # Pollutant emissions
param crack_Cost{CR_MODE, DIST_CR} >= 0 ; # Cost of process
param crack_Waste_Cost{CR_MODE, DIST_CR} >= 0 ; # Residue disposal cost
param crack_Max_capacity{CR_MODE} >= 0 ; # Maximum capacity
param crack_Equipment_Setup_Period{CR_MODE} >= 0 ; # Equipment setup period
param crack_Equipment_Setup_Cost{CR_MODE} >=0 ; # Equipment setup cost
## Lubrication
param lube_Yield{LUBRICATING} >= 0 ; # Yield of products
param lube_Pollute{L_MODE, DIST_L, POLLUT} ; # Pollutant emissions
param lube_Waste_Cost{L_MODE, DIST_L} >= 0 ; # Residue disposal cost
param lube_Cost{L_MODE, DIST_L} >= 0 ; # Cost of process
param lube_Max_capacity{L_MODE} >= 0 ; # Maximum production of lube oil
param lube_Equipment_Setup_Period{L_MODE} >= 0 ;# Equipment setup period
param lube_Equipment_Setup_Cost{L_MODE} >= 0 ; # Equipment setup cost
param lube_limit_Min = 0 ; # Minimum production of lube oil
param lube_limit_Max >= lube_limit_Min ; # Maximum production of lube oil
## Intermediate components
param Intermed_Octane{INTERMED} >= 0 ; # Octane number
param Intermed_VaporPressure{INTERMED} >= 0 ; # Vapor pressure
## Blending
param blending_Cost{PROD} >= 0 ; # Cost of blending
## Products
param prod_Octane_Min{PROD} >= 0 ; # Minimum octane number for final products
param prod_VaporPressure_Max{PROD} >= 0 ; # Maximum vapor pressure for final products
param prod_Premium_Regular_Gas_Min >= 0 ; # Minimum production of premium gas
param prod_FuelOil_Ratio{INTERMED} >= 0 ; # Ratios for fuel oil production components
## Storage
param storage_Capacity{PROD} >=0 ; # Storage capacity for each product
param storage_Cost{PROD} >= 0 ; # Storage cost per product
param storage_Waste{PROD} >= 0 ; # Waste during storage
## Product delivery
param delivery_Cost{PROD, STAT} >= 0 ; # Delivery cost per product to each station
## Plant
param plant_Shutdown_Period >= 0 ; # Equipment setup period
param plant_Shutdown_Cost >= 0 ; # Equipment setup cost
param plant_Const_Cost >= 0 ; # Plant fixed costs
## Market
param seasonal_Base_Demand{PROD, 1..nPeriod} >= 0 ; # Base demand for products per week.
param seasonal_Base_Price {PROD, 1..nPeriod} >= 0 ; # Base price for products per week.
# Price elasticity
param nStep integer > 0 ; # Number of steps for price elasticity
param price_nStep_Value{1..nStep+1} ; # Step values for price elasticity
param demand_nStep_Value{1..nStep+1} ; # Step values for price elasticity
## Finance
param discount_Rate >= 0 ; # Discount rate for future cash flows
param initial_Cash >= 0 ; # Initial cash available
## Loans
set LOANS; # Set of loan periods
set LOAN_param; # Parameters of loans (term, interest, Max_Money)
param loan{LOANS, LOAN_param} >= 0 ; # Conditions for obtaining credit
### VARIABLES
## Plant working
var Plant_Working{t in 1..nPeriod} binary; # 1 if the plant is running. 0 if the plant is shutdown
## Distillation
var Crude_Supply{D_MODE, CRUD, 1..nPeriod} >= 0 ; # Amount of crude supplied
var Distill_X{D_MODE, 1..nPeriod} binary ; # Additional binary variable for selecting the operating mode of the equipment
## Reforming
var Distill_to_Reforming{R_MODE, DIST_R, 1..nPeriod} >= 0 ; # Quantity of distillation products used for Reforming
var Reform_X{R_MODE, 1..nPeriod} binary ; # Additional binary variable for selecting the operating mode of the equipment
## Cracking
var Distill_to_Cracking{CR_MODE, DIST_CR, 1..nPeriod} >= 0 ;# Quantity of distillation products used for Cracking
var Cracking_X{CR_MODE, 1..nPeriod} binary ; # Additional binary variable for selecting the operating mode of the equipment
## Lubricating
var Distill_to_Lubricating{L_MODE, DIST_L, 1..nPeriod} >= 0 ;# Quantity of distillation products used for Lubricating
var Lubricating_X{L_MODE, 1..nPeriod} binary ; # Additional binary variable for selecting the operating mode of the equipment
## Blending:
var Blending{BLENDING, 1..nPeriod} >= 0 ; # Amount of ingredients mixed to obtain final products
## Demand
var Demand{PROD, STAT, 1..nPeriod, 1..nStep} >= 0 ; # Demand for each pr oduct at each station over time
var X{PROD, STAT, 1..nPeriod, 1..nStep} binary ; # Additional binary variable for demand steps (1 if for product p in period t the price is selected at step nStep, or 0 otherwise)
## Storage
var Storage_Fraction{p in PROD, t in 1..nPeriod} = # Amount of each product in Storage each period
sum{tt in 1..t} (sum{(i,p) in BLENDING} Blending[i,p,tt]
- sum{s in STAT, n in 1..nStep} Demand[p,s,tt,n]) * (1-storage_Waste[p]/100) ;
## Loan
# Amount of loan taken every period
var Loan_In{l in LOANS, 1..nPeriod-1} >= 0 , <= loan[l,'Max_Money'] ;
# Amount of loan taken every period
var Loan_Out{l in LOANS, t in 2..nPeriod} = Loan_In[l,t-1] * (1+(loan[l, 'interest']/nPeriodByYear)/100);
## Pollutant emissions
var Waste_Pollutant{p in POLLUT, t in 1..nPeriod} =
# Pollution from waste disposal from the Distillation process
sum{m in D_MODE, c in CRUD} Crude_Supply[m,c,t] * (1 - sum{d in DIST}distill_Yield[m,c,d]) * distill_Pollute[m,c,p]
# Pollution from waste disposal from the Reforming process
+ sum{m in R_MODE, c in DIST_R} Distill_to_Reforming[m,c,t] * (1 - sum{d in REF} reform_Yield[m,c,d]) * reform_Pollute[m,c,p]
# Pollution from waste disposal from the Cracking process
+ sum{m in CR_MODE, c in DIST_CR} Distill_to_Cracking[m,c,t] * (1 - sum{d in CRACK} crack_Yield[m,c,d]) * crack_Pollute[m,c,p]
# Pollution from waste disposal from the Lubricating process
+ sum{m in L_MODE, c in DIST_L} Distill_to_Lubricating[m,c,t] * (1 - sum{d in LUBR} lube_Yield[m,c,d]) * lube_Pollute[m,c,p];
## Cash flow with incomes and costs
var CashFlow{t in 1..nPeriod} =
# sales income
sum{p in PROD, s in STAT, n in 1..nStep} Demand[p,s,t,n] * (seasonal_Base_Price[p,t] * (1 + price_nStep_Value[n]/100) - delivery_Cost[p,s])
# minus the cost of purchasing crude oil + the costs of the Distillation process + costs for disposal of waste from the Distillation process
- sum{m in D_MODE, c in CRUD} Crude_Supply[m,c,t] * (crude_Cost[c,t] + distill_Cost[m,c] + (1 - sum{d in DIST}distill_Yield[m,c,d]) * distill_Waste_Cost[m,c])
# minus the costs of the Reforming process + costs for disposal of waste from the Reforming process
- sum{m in R_MODE, c in DIST_R} Distill_to_Reforming[m,c,t] * (reform_Cost[m,c] + (1 - sum{d in REF} reform_Yield[m,c,d]) * reform_Waste_Cost[m,c])
# minus the costs of the Cracking process + costs for disposal of waste from the Cracking process
- sum{m in CR_MODE, c in DIST_CR} Distill_to_Cracking[m,c,t] * (crack_Cost[m,c] + (1 - sum{d in CRACK} crack_Yield[m,c,d]) * crack_Waste_Cost[m,c])
# minus the costs of the Lubricating process + costs for disposal of waste from the Lubricating process
- sum{m in L_MODE, c in DIST_L} Distill_to_Lubricating[m,c,t] * (lube_Cost[m,c] + (1 - sum{d in LUBR} lube_Yield[m,c,d]) * lube_Waste_Cost[m,c])
# minus the costs of reconfiguring equipment (if available)
- (if t > 1 then /*Nonliner piece*/
# Distillation equipment
sum{m in D_MODE} (if Distill_X[m,t] - Distill_X[m,t-1] > 0 then distill_Equipment_Setup_Cost[m] else 0)
# Reforming equipment
+ sum{m in R_MODE} (if Reform_X[m,t] - Reform_X[m,t-1] > 0 then reform_Equipment_Setup_Cost[m] else 0)
# Cracking equipment
+ sum{m in CR_MODE} (if Cracking_X[m,t] - Cracking_X[m,t-1] > 0 then crack_Equipment_Setup_Cost[m] else 0)
# Lubricating equipment
+ sum{m in L_MODE}(if Lubricating_X[m,t] - Lubricating_X[m,t-1] > 0 then lube_Equipment_Setup_Cost[m] else 0)
else 0)
# minus the cost of the Blending
- sum{(i,p) in BLENDING} Blending[i,p,t] * blending_Cost[p]
# minus cost of shutdown
- (1 - Plant_Working[t]) * plant_Shutdown_Cost
# minus the storage cost
- sum{p in PROD} Storage_Fraction[p,t] * storage_Cost[p]
# minus fixed plant costs
- plant_Const_Cost
# plus the amount of the loan received
+ (if t = nPeriod then 0 else sum{l in LOANS} Loan_In[l,t])
# minus the amount of repaid loans with accrued interest
- (if t = 1 then 0 else sum{l in LOANS} Loan_Out[l,t]);
### OBJECTIVE FUNCTION
# Maximize the total profit considering all incomes and costs, discounted by the discount rate
maximize Total_Profit:
sum{t in 1..nPeriod} CashFlow[t] / (1 + (discount_Rate/nPeriodByYear)/100)^t ;
### CONSTRAINTS
subject to
## Distillation
# Ensure that total supply of crude oil does not exceed the maximum capacity.
Crude_Supply_Min_Max{c in CRUD, t in 1..nPeriod}:crude_Min[c] <= sum{m in D_MODE} Crude_Supply[m,c,t] <= crude_Max_capacity[c];
# Ensure distillation capacity does not exceed the maximum. Сapacity is reduced during downtime caused by equipment reconfiguring.
DistillCapacity_Max {m in D_MODE, t in 1..nPeriod}: sum{c in CRUD} Crude_Supply[m,c,t] <= distill_Max_capacity [m]
/* Nonliner piece*/ * (if t > 1 then (if Distill_X[m,t] > Distill_X[m,t-1] then 1 - distill_Equipment_Setup_Period[m] else 1) else 1) ;
# Ensure only one mode per period
ForEachPeriodOnlyOne_Distill_X { t in 1..nPeriod}: sum{m in D_MODE} Distill_X[m,t] <= 1 ;
# Ensure that Crude_Supply > 0 only when Distill_X > 0
Distill_{m in D_MODE, t in 1..nPeriod}: sum{c in CRUD} Crude_Supply[m,c,t] <= Distill_X[m,t] * 10e5;
## Reforming
# Ensure reforming capacity does not exceed the maximum. Сapacity is reduced during downtime caused by equipment reconfiguring.
Reforming_Capacity_Max {m in R_MODE, t in 1..nPeriod}: sum{c in DIST_R} Distill_to_Reforming[m,c,t] <= reform_Max_capacity[m]
/* Nonliner piece*/ * (if t > 1 then (if Reform_X[m,t] > Reform_X[m,t-1] then 1 - reform_Equipment_Setup_Period[m] else 1) else 1);
# Ensure only one mode per period
ForEachPeriodOnlyOne_Reform_X { t in 1..nPeriod}: sum{m in R_MODE} Reform_X[m,t] <= 1 ;
# Ensure that Distill_to_Reforming > 0 only when Reform_X > 0
Reform_{m in R_MODE, t in 1..nPeriod}:sum{c in DIST_R}Distill_to_Reforming[m,c,t] <= Reform_X[m,t] * 10e5;
## Cracking
# Ensure cracking capacity does not exceed the maximum. Сapacity is reduced during downtime caused by equipment reconfiguring.
CrackingCapacity_Max {m in CR_MODE, t in 1..nPeriod}: sum{c in DIST_CR} Distill_to_Cracking[m,c,t] <= crack_Max_capacity[m]
/* Nonliner piece*/ * (if t > 1 then (if Cracking_X[m,t] > Cracking_X[m,t-1] then 1 - crack_Equipment_Setup_Period[m] else 1) else 1);
# Ensure only one mode per period
ForEachPeriodOnlyOne_Cracking_X { t in 1..nPeriod}: sum{m in CR_MODE} Cracking_X[m,t] <= 1 ;
# Ensure that Distill_to_Cracking > 0 only when Cracking_X > 0
Cracking_{m in CR_MODE, t in 1..nPeriod}: sum{c in DIST_CR} Distill_to_Cracking[m,c,t] <= Cracking_X[m,t] * 10e5;
## Lubricating
# Ensure cracking does not exceed the minimum & maximum volume
Lube_Oil_Min_Max {t in 1..nPeriod}:
lube_limit_Min <= sum{(m,d,l)in LUBRICATING} Distill_to_Lubricating[m,d,t] * lube_Yield[m,d,l] <= lube_limit_Max ;
# Сapacity is reduced during downtime caused by equipment reconfiguring.
Lube_Oil_Capacity_Max {m in L_MODE, t in 1..nPeriod}: sum{c in DIST_L} Distill_to_Lubricating[m,c,t] <= lube_Max_capacity[m]
/* Nonliner piece*/ * (if t > 1 then (if Lubricating_X[m,t] > Lubricating_X[m,t-1] then 1 - lube_Equipment_Setup_Period[m] else 1) else 1); # Nonliner piece
# Ensure only one mode per period
ForEachPeriodOnlyOne_Lubricating_X { t in 1..nPeriod}: sum{m in L_MODE} Lubricating_X[m,t] <= 1 ;
# Ensure that Distill_to_Lubricating> 0 only when Lubricating_X > 0
Lubricating_{m in L_MODE, t in 1..nPeriod}: sum{c in DIST_L}Distill_to_Lubricating[m,c,t] <= Lubricating_X[m,t] * 10e5;
## Blending
PremiumRegularGasRatio {t in 1..nPeriod}: # Premium gasoline production: at least 40% of regular gasoline production
sum{(i,p) in BLENDING: p='Premium Gasoline'} Blending[i,p,t] >=
sum{(i,p) in BLENDING: p='Regular Gasoline'} Blending[i,p,t] * prod_Premium_Regular_Gas_Min/100 ;
OctaneNumberMin {p in PROD, t in 1..nPeriod: p = 'Premium Gasoline'}:# Ensure octane number requirements for final products
sum{(i,p) in BLENDING} Blending[i,p,t] * Intermed_Octane[i] >=
sum{(ii,p) in BLENDING} Blending[ii,p,t] * prod_Octane_Min[p] ;
OctaneNumberMin_2 {p in PROD, t in 1..nPeriod: p = 'Regular Gasoline'}:# Ensure octane number requirements for final products
sum{(i,p) in BLENDING} Blending[i,p,t] * Intermed_Octane[i] >=
sum{(ii,p) in BLENDING} Blending[ii,p,t] * prod_Octane_Min[p] ;
VaporPressure_Max {p in PROD, t in 1..nPeriod: p='Jet Fuel'}:# Ensure vapor pressure limits for products
sum{(i,p) in BLENDING} Blending[i,p,t] * Intermed_VaporPressure[i] <=
sum{(i,p) in BLENDING} Blending[i,p,t] * prod_VaporPressure_Max[p] ;
FuelOilRatio {(i,p) in BLENDING, t in 1..nPeriod: p = 'Fuel Oil'}: # Maintain the correct ratio for fuel oil production
Blending['Residuum',p, t] = Blending[i,p,t] / prod_FuelOil_Ratio[i] ;
## Storage
# Ensure storage fractions are non-negative and within capacity
Storage_non_negative {p in PROD, t in 1..nPeriod}:
0 <= Storage_Fraction[p,t] <= storage_Capacity[p];
## Financial calculations
CashFlow_Balance{t in 1..nPeriod}: # Cash flow balance
initial_Cash
+ sum{tt in 1..t}CashFlow[tt] >= 0;
## Ensure sufficient distillation output
Distillation_Out {d in DIST, t in 1..nPeriod}:
sum{m in D_MODE, c in CRUD} Crude_Supply[m,c,t] * distill_Yield[m,c,d]
>=
sum{m in R_MODE, dd in DIST_R: dd=d} Distill_to_Reforming[m,dd,t]
+ sum{m in CR_MODE, dd in DIST_CR: dd=d} Distill_to_Cracking[m,dd,t]
+ sum{m in L_MODE, dd in DIST_L: dd=d} Distill_to_Lubricating[m,dd,t] ;
## Balance INTERMED products before blending
INTERMED_Balance{i in INTERMED, t in 1..nPeriod}:
sum{(i,p) in BLENDING} Blending[i,p,t] <=
sum{(m,c,d) in DISTILLATION:d=i} Crude_Supply[m,c,t] * distill_Yield[m,c,d]
- sum{m in R_MODE, d in DIST_R: d=i} Distill_to_Reforming[m,d,t]
- sum{m in CR_MODE, d in DIST_CR: d=i} Distill_to_Cracking[m,d,t]
- sum{m in L_MODE, d in DIST_L: d=i} Distill_to_Lubricating[m,d,t]
+ sum{(m,d,r) in REFORMING: r=i} Distill_to_Reforming[m,d,t] * reform_Yield[m,d,r]
+ sum{(m,d,cr) in CRACKING: cr=i} Distill_to_Cracking[m,d,t] * crack_Yield[m,d,cr]
+ sum{(m,d,l) in LUBRICATING: l=i} Distill_to_Lubricating[m,d,t] * lube_Yield[m,d,l] ;
## Prices elastisity
ForEachPeriodOnlyOne_X {p in PROD, s in STAT, t in 1..nPeriod}:
sum{i in 1..nStep} X [p,s,t,i] = 1 ; # Ensure only one price per product per period
# Double restriction. Ensure demand is within the range dictated by price steps.
# The constraint of type min must be set after solving a model without this constraint. #Use Min constraint after ensuring that it does not conflict with other model constraints.
Demand_Min {p in PROD, s in STAT, t in 1..nPeriod, n in 1..nStep: p!='Lube Oil'}:
Demand[p,s,t,n] >= X[p,s,t,n] * seasonal_Base_Demand[p,t] * (1+demand_nStep_Value[n]/100) ;
Demand_Max {p in PROD, s in STAT, t in 1..nPeriod, n in 1..nStep}:
Demand[p,s,t,n] <= X[p,s,t,n] * seasonal_Base_Demand[p,t] * (1+demand_nStep_Value[n+1]/100) ;
## Shutdown contstraints
# The number of working periods is equal to the total number of periods under consideration minus the duration of the planned suspension
Plant_Working_nPeriods: sum{t in 1..nPeriod - plant_Shutdown_Period + 1} Plant_Working[t] = nPeriod - plant_Shutdown_Period;
# Additionally, there is a restriction in case of a longer (more than 1 period) plant shutdown.
Shutdown_Distill{t in 1..nPeriod - plant_Shutdown_Period + 1}:
sum{m in D_MODE, c in CRUD, tt in 0..plant_Shutdown_Period-1} Crude_Supply[m,c,t+tt] <= Plant_Working[t] * 10e5;
Overwriting oil_refining.mod
5. Solve problem#
# Read the model
model_file = 'oil_refining.mod'
ampl.read(model_file)
import requests
data_filename = "data.json"
url = "https://raw.githubusercontent.com/ampl/colab.ampl.com/master/authors/mikhail/Petroleum_refining/data.json"
response = requests.get(url)
if response.status_code == 200:
with open(data_filename, 'wb') as file:
file.write(response.content)
print(f"File downloaded successfully as {data_filename}")
else:
print(f"Failed to download file. Status code: {response.status_code}")
File downloaded successfully as data.json
# Read the data from json
with open(data_filename, 'r') as file: # Open and read the JSON file
data = json.load(file) # Load the JSON data into a Python dictionary
# Convert data for each processing type to DataFrames and then to a list of tuples
# Each tuple corresponds to a combination of attributes for a specific processing type
ampl.set['DISTILLATION'] = pd.DataFrame(data['distill_Yield']).apply(lambda row: (row['D_MODE'], row['CRUD'], row['DIST']), axis=1)
ampl.set['REFORMING'] = pd.DataFrame(data['reform_Yield']).apply(lambda row: (row['R_MODE'], row['DIST_R'], row['REF']), axis=1)
ampl.set['CRACKING'] = pd.DataFrame(data['crack_Yield']).apply(lambda row: (row['CR_MODE'], row['DIST_CR'], row['CRACK']), axis=1)
ampl.set['LUBRICATING'] = pd.DataFrame(data['lube_Yield']).apply(lambda row: (row['L_MODE'], row['DIST_L'], row['LUBR']), axis=1)
ampl.set['BLENDING'] = pd.DataFrame(data['blending_recipe']).apply(lambda row: (row['INTERMED'], row['PROD']), axis=1)
### PARAMETERS
# Calculate the number of periods and steps based on the unique values in relevant data columns
ampl.param['nPeriod'] = len(pd.DataFrame(data['crude_Cost'])['nPeriod'].unique()) # `nPeriod` is the count of unique periods in the 'crude_Cost' data
ampl.param['nStep'] = len(pd.DataFrame(data['demand_nStep_Value'])['nStep'].unique()) - 1 # `nStep` is the count of unique steps in 'demand_nStep_Value'
ampl.param['nPeriodByYear'] = 12 # Define a constant for the number of periods per year
# Define the sets to be processed
sets_ = ['CRUD','DIST', 'POLLUT', 'D_MODE', 'REF', 'R_MODE', 'CRACK', 'CR_MODE', 'LUBR', 'L_MODE', 'PROD', 'LOAN_param','LOANS', 'STAT']
for key_dict in data.keys(): # Iterate over each key in the JSON data dictionary.
if key_dict in sets_: # Check if the current key is in the predefined 'sets_' list.
df = pd.DataFrame(data[key_dict]) # Convert the corresponding data into a DataFrame.
if len(df.columns) > 1: # Check if the DataFrame has multiple columns.
# Convert each row in the DataFrame to a tuple and store these tuples in a set.
ampl.set[key_dict] = set(tuple(row) for row in df.itertuples(index=False, name=None))
else: # If there is only one column
ampl.set[key_dict] = set(df.iloc[:, 0]) # Convert the single column to a set
else: # If the current key is not in the 'sets_' list
df = pd.DataFrame(data[key_dict]) # Convert the corresponding data into a DataFrame.
# Get the columns other than the key_dict
set_of_columns = [col for col in df.columns if col not in key_dict] # Get a list of all column(save order) names except the current key (key_dict)
set_of_columns_2 = df.columns.difference([key_dict]).tolist() # Get a list of all column names except the current key (key_dict)
if len(set_of_columns_2) > 1: # If there are multiple columns besides the current key
if key_dict != 'blending_recipe': # Special case handling for 'blending_recipe' to avoid conflicts.
# Set the DataFrame's index to these columns and convert to a dictionary.
ampl.param[key_dict] = df.set_index(set_of_columns)[key_dict].to_dict()
else:
if len(set_of_columns_2) == 1: # If there is exactly one other column besides the current key
ampl.param[key_dict] = df.set_index(set_of_columns_2)[key_dict].to_dict() # Convert the DataFrame into a dictionary.
else: # If there are no other columns
ampl.param[key_dict] = df[key_dict].squeeze() # Convert the DataFrame to a Series or a scalar and store it in 'ampl.param'
ampl.option['highs_options'] = 'outlev=1 timelim=60'
ampl.solve(solver='highs')
HiGHS 1.7.1: tech:outlev = 1
lim:time = 60
Running HiGHS 1.7.1 (git hash: dcf3813): Copyright (c) 2024 HiGHS under MIT licence terms
Coefficient ranges:
Matrix [5e-03, 1e+06]
Cost [1e-03, 1e+05]
Bound [4e-01, 1e+07]
RHS [1e+00, 2e+06]
Presolving model
1406 rows, 1322 cols, 13030 nonzeros 0s
1328 rows, 1255 cols, 13057 nonzeros 0s
Solving MIP model with:
1328 rows
1255 cols (491 binary, 9 integer, 0 implied int., 755 continuous)
13057 nonzeros
Nodes | B&B Tree | Objective Bounds | Dynamic Constraints | Work
Proc. InQueue | Leaves Expl. | BestBound BestSol Gap | Cuts InLp Confl. | LpIters Time
0 0 0 0.00% 322886748.5216 -inf inf 0 0 0 0 0.1s
0 0 0 0.00% 2934787.614344 -inf inf 0 0 8 1064 0.1s
L 0 0 0 0.00% 2895816.500734 2752968.201249 5.19% 171 67 177 1221 3.6s
0 0 0 0.00% 2895816.500734 2752968.201249 5.19% 173 37 194 7678 14.0s
L 0 0 0 0.00% 2895816.500734 2763523.36106 4.79% 173 37 194 7678 16.1s
T 25 0 10 87.50% 2784390.201046 2765077.040236 0.70% 254 74 491 16207 17.7s
T 30 0 11 93.75% 2784390.201046 2783808.156296 0.02% 257 74 506 16775 17.7s
Solving report
Status Optimal
Primal bound 2783808.1563
Dual bound 2783808.1563
Gap 0% (tolerance: 0.01%)
Solution status feasible
2783808.1563 (objective)
0 (bound viol.)
1.39888101103e-14 (int. viol.)
0 (row viol.)
Timing 17.72 (total)
0.05 (presolve)
0.00 (postsolve)
Nodes 32
LP iterations 16838 (total)
4905 (strong br.)
264 (separation)
9546 (heuristics)
HiGHS 1.7.1: optimal solution; objective 2783808.156
16838 simplex iterations
32 branching nodes
------------ WARNINGS ------------
WARNING: "Tolerance violations"
Type MaxAbs [Name] MaxRel [Name]
objective(s) 2E+05 9E-02
Documentation: mp.ampl.com/modeling-tools.html#automatic-solution-check.
6. Retrieve solution and export it to an Excel file#
Write the solution into an *.xlsx file.
amplvar = dict()
# Create an ExcelWriter object for saving DataFrames to an Excel file at the specified path
with pd.ExcelWriter('oil_refining.xlsx') as writer:
# Generate a list of all variable names from the AMPL model
list_of_ampl_variables = [item[0] for item in ampl.get_variables()]
# Iterate over each variable name in the list
for key_ampl in list_of_ampl_variables:
# Skip certain variables that are not to be processed (these variables won't be included in the output)
if key_ampl not in ['X', 'Cracking_X', 'Distill_X', 'Lubricating_X', 'Reform_X']:
# Convert the AMPL variable data to a pandas DataFrame
df = ampl.var[key_ampl].to_pandas()
# Filter the DataFrame to include only rows where the variable's value is greater than a small threshold (10^-5)
filtered_df = df[df[f"{key_ampl}.val"] > 10e-5]
# Save the filtered DataFrame to the corresponding sheet in the Excel file
if not filtered_df.empty: # Ensure that only non-empty DataFrames are saved
filtered_df.to_excel(writer, sheet_name=key_ampl, index=True)
# Save the filtered DataFrame to a dictionary
#amplvar[key_ampl] = filtered_df
7. Display the solution#
%%ampl_eval
display Plant_Working, Crude_Supply, Distill_to_Reforming, Distill_to_Cracking, Distill_to_Lubricating, Blending, OctaneNumberMin, VaporPressure_Max, Storage_Fraction, Demand, Loan_In, Loan_Out, CashFlow, Waste_Pollutant;
printf {p in PROD, t in 1..nPeriod}: "Octane number for products: %u %s %6.2f\n", t, p, sum{(i,p) in BLENDING} Blending[i,p,t] * Intermed_Octane[i] / sum{(ii,p) in BLENDING}(if Blending[ii,p,t] = 0 then 1 else Blending[ii,p,t]);
printf {p in PROD, t in 1..nPeriod: p='Jet Fue'}: "Vapor pressure limits of product Jet Fuel: %u %s %6.2f\n", t, p, sum{(i,p) in BLENDING} Blending[i,p,t] * Intermed_VaporPressure[i] / (if sum{(ii,p) in BLENDING} Blending[ii,p,t] = 0 then 1 else sum{(ii,p) in BLENDING}Blending[ii,p,t]) ;
printf {t in 1..nPeriod}: "Premium / Regular percentage: %u %6.2f\n", t,
sum{(i,p) in BLENDING: p ='Premium Gasoline'} Blending[i,p,t] / (if sum{(ii,pp) in BLENDING: pp ='Regular Gasoline'}Blending[ii,pp,t] = 0 then 1 else sum{(ii,pp) in BLENDING: pp ='Regular Gasoline'}Blending[ii,pp,t]) ;
printf {(i,p) in BLENDING, t in 1..nPeriod: p='Fuel Oil'}: "Production Fuel Oil ratio: %u %s %6.2f\n", t, i,
Blending[i,p,t] / (if Blending['Residuum',p,t] = 0 then 1 else Blending['Residuum',p,t]);
Plant_Working [*] :=
1 1
2 1
3 0
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
;
# $2 = Distill_to_Reforming
: Crude_Supply $2 :=
D1 Crude1 1 0 .
D1 Crude1 2 0 .
D1 Crude1 3 0 .
D1 Crude1 4 0 .
D1 Crude1 5 4341.18 .
D1 Crude1 6 0 .
D1 Crude1 7 0 .
D1 Crude1 8 0 .
D1 Crude1 9 0 .
D1 Crude1 10 0 .
D1 Crude1 11 0 .
D1 Crude1 12 0 .
D1 Crude2 1 0 .
D1 Crude2 2 0 .
D1 Crude2 3 0 .
D1 Crude2 4 27235.2 .
D1 Crude2 5 30000 .
D1 Crude2 6 30000 .
D1 Crude2 7 30000 .
D1 Crude2 8 30000 .
D1 Crude2 9 30000 .
D1 Crude2 10 25667.5 .
D1 Crude2 11 22825.2 .
D1 Crude2 12 25149.7 .
D2 Crude1 1 25116.9 .
D2 Crude1 2 40000 .
D2 Crude1 3 0 .
D2 Crude1 4 0 .
D2 Crude1 5 0 .
D2 Crude1 6 0 .
D2 Crude1 7 0 .
D2 Crude1 8 0 .
D2 Crude1 9 0 .
D2 Crude1 10 0 .
D2 Crude1 11 0 .
D2 Crude1 12 0 .
D2 Crude2 1 0 .
D2 Crude2 2 9176.88 .
D2 Crude2 3 0 .
D2 Crude2 4 0 .
D2 Crude2 5 0 .
D2 Crude2 6 0 .
D2 Crude2 7 0 .
D2 Crude2 8 0 .
D2 Crude2 9 0 .
D2 Crude2 10 0 .
D2 Crude2 11 0 .
D2 Crude2 12 0 .
R1 'Heavy Naphta' 1 . 0
R1 'Heavy Naphta' 2 . 0
R1 'Heavy Naphta' 3 . 0
R1 'Heavy Naphta' 4 . 0
R1 'Heavy Naphta' 5 . 0
R1 'Heavy Naphta' 6 . 0
R1 'Heavy Naphta' 7 . 0
R1 'Heavy Naphta' 8 . 0
R1 'Heavy Naphta' 9 . 0
R1 'Heavy Naphta' 10 . 0
R1 'Heavy Naphta' 11 . 0
R1 'Heavy Naphta' 12 . 0
R1 'Light Naphta' 1 . 0
R1 'Light Naphta' 2 . 0
R1 'Light Naphta' 3 . 0
R1 'Light Naphta' 4 . 0
R1 'Light Naphta' 5 . 0
R1 'Light Naphta' 6 . 0
R1 'Light Naphta' 7 . 0
R1 'Light Naphta' 8 . 0
R1 'Light Naphta' 9 . 0
R1 'Light Naphta' 10 . 0
R1 'Light Naphta' 11 . 0
R1 'Light Naphta' 12 . 0
R1 'Medium Naphta' 1 . 0
R1 'Medium Naphta' 2 . 0
R1 'Medium Naphta' 3 . 0
R1 'Medium Naphta' 4 . 0
R1 'Medium Naphta' 5 . 0
R1 'Medium Naphta' 6 . 0
R1 'Medium Naphta' 7 . 0
R1 'Medium Naphta' 8 . 0
R1 'Medium Naphta' 9 . 0
R1 'Medium Naphta' 10 . 0
R1 'Medium Naphta' 11 . 0
R1 'Medium Naphta' 12 . 0
R2 'Heavy Naphta' 1 . 3289.03
R2 'Heavy Naphta' 2 . 6584.9
R2 'Heavy Naphta' 3 . 0
R2 'Heavy Naphta' 4 . 4360.94
R2 'Heavy Naphta' 5 . 5536.63
R2 'Heavy Naphta' 6 . 4019.59
R2 'Heavy Naphta' 7 . 3760.46
R2 'Heavy Naphta' 8 . 3894.68
R2 'Heavy Naphta' 9 . 4147.09
R2 'Heavy Naphta' 10 . 3685.4
R2 'Heavy Naphta' 11 . 3214.41
R2 'Heavy Naphta' 12 . 3492.84
R2 'Light Naphta' 1 . 0
R2 'Light Naphta' 2 . 0
R2 'Light Naphta' 3 . 0
R2 'Light Naphta' 4 . 0
R2 'Light Naphta' 5 . 0
R2 'Light Naphta' 6 . 0
R2 'Light Naphta' 7 . 0
R2 'Light Naphta' 8 . 0
R2 'Light Naphta' 9 . 0
R2 'Light Naphta' 10 . 0
R2 'Light Naphta' 11 . 0
R2 'Light Naphta' 12 . 0
R2 'Medium Naphta' 1 . 0
R2 'Medium Naphta' 2 . 0
R2 'Medium Naphta' 3 . 0
R2 'Medium Naphta' 4 . 0
R2 'Medium Naphta' 5 . 0
R2 'Medium Naphta' 6 . 0
R2 'Medium Naphta' 7 . 0
R2 'Medium Naphta' 8 . 0
R2 'Medium Naphta' 9 . 0
R2 'Medium Naphta' 10 . 0
R2 'Medium Naphta' 11 . 0
R2 'Medium Naphta' 12 . 0
;
# $2 = Distill_to_Lubricating
: Distill_to_Cracking $2 :=
CR1 'Heavy Oil' 1 0 .
CR1 'Heavy Oil' 2 0 .
CR1 'Heavy Oil' 3 0 .
CR1 'Heavy Oil' 4 0 .
CR1 'Heavy Oil' 5 0 .
CR1 'Heavy Oil' 6 0 .
CR1 'Heavy Oil' 7 0 .
CR1 'Heavy Oil' 8 0 .
CR1 'Heavy Oil' 9 0 .
CR1 'Heavy Oil' 10 0 .
CR1 'Heavy Oil' 11 0 .
CR1 'Heavy Oil' 12 0 .
CR1 'Light Oil' 1 0 .
CR1 'Light Oil' 2 0 .
CR1 'Light Oil' 3 0 .
CR1 'Light Oil' 4 0 .
CR1 'Light Oil' 5 0 .
CR1 'Light Oil' 6 0 .
CR1 'Light Oil' 7 0 .
CR1 'Light Oil' 8 0 .
CR1 'Light Oil' 9 0 .
CR1 'Light Oil' 10 0 .
CR1 'Light Oil' 11 0 .
CR1 'Light Oil' 12 0 .
CR2 'Heavy Oil' 1 905.436 .
CR2 'Heavy Oil' 2 1555.14 .
CR2 'Heavy Oil' 3 0 .
CR2 'Heavy Oil' 4 0 .
CR2 'Heavy Oil' 5 0 .
CR2 'Heavy Oil' 6 1.39922e-11 .
CR2 'Heavy Oil' 7 1418 .
CR2 'Heavy Oil' 8 1394.04 .
CR2 'Heavy Oil' 9 1394.04 .
CR2 'Heavy Oil' 10 0 .
CR2 'Heavy Oil' 11 395.345 .
CR2 'Heavy Oil' 12 954.904 .
CR2 'Light Oil' 1 835.253 .
CR2 'Light Oil' 2 1601.69 .
CR2 'Light Oil' 3 0 .
CR2 'Light Oil' 4 871.527 .
CR2 'Light Oil' 5 997.913 .
CR2 'Light Oil' 6 1014.29 .
CR2 'Light Oil' 7 871.887 .
CR2 'Light Oil' 8 235.099 .
CR2 'Light Oil' 9 235.099 .
CR2 'Light Oil' 10 674.298 .
CR2 'Light Oil' 11 524.828 .
CR2 'Light Oil' 12 308.239 .
L1 Residuum 1 . 0
L1 Residuum 2 . 0
L1 Residuum 3 . 0
L1 Residuum 4 . 0
L1 Residuum 5 . 0
L1 Residuum 6 . 0
L1 Residuum 7 . 0
L1 Residuum 8 . 0
L1 Residuum 9 . 0
L1 Residuum 10 . 0
L1 Residuum 11 . 0
L1 Residuum 12 . 0
L2 Residuum 1 . 0
L2 Residuum 2 . 0
L2 Residuum 3 . 0
L2 Residuum 4 . 0
L2 Residuum 5 . 0
L2 Residuum 6 . 0
L2 Residuum 7 . 0
L2 Residuum 8 . 0
L2 Residuum 9 . 0
L2 Residuum 10 . 0
L2 Residuum 11 . 0
L2 Residuum 12 . 0
;
: Blending :=
'Cracked Oil' 'Fuel Oil' 1 971.979
'Cracked Oil' 'Fuel Oil' 2 1769.69
'Cracked Oil' 'Fuel Oil' 3 0
'Cracked Oil' 'Fuel Oil' 4 522.916
'Cracked Oil' 'Fuel Oil' 5 598.748
'Cracked Oil' 'Fuel Oil' 6 554.286
'Cracked Oil' 'Fuel Oil' 7 611.245
'Cracked Oil' 'Fuel Oil' 8 865.96
'Cracked Oil' 'Fuel Oil' 9 865.96
'Cracked Oil' 'Fuel Oil' 10 404.579
'Cracked Oil' 'Fuel Oil' 11 520.476
'Cracked Oil' 'Fuel Oil' 12 681.494
'Cracked Oil' 'Jet Fuel' 1 0
'Cracked Oil' 'Jet Fuel' 2 0
'Cracked Oil' 'Jet Fuel' 3 0
'Cracked Oil' 'Jet Fuel' 4 0
'Cracked Oil' 'Jet Fuel' 5 0
'Cracked Oil' 'Jet Fuel' 6 54.2857
'Cracked Oil' 'Jet Fuel' 7 649.249
'Cracked Oil' 'Jet Fuel' 8 0
'Cracked Oil' 'Jet Fuel' 9 0
'Cracked Oil' 'Jet Fuel' 10 0
'Cracked Oil' 'Jet Fuel' 11 0
'Cracked Oil' 'Jet Fuel' 12 0
'Cracked gasoline' 'Premium Gasoline' 1 591.834
'Cracked gasoline' 'Premium Gasoline' 2 1073.32
'Cracked gasoline' 'Premium Gasoline' 3 0
'Cracked gasoline' 'Premium Gasoline' 4 0
'Cracked gasoline' 'Premium Gasoline' 5 0
'Cracked gasoline' 'Premium Gasoline' 6 344.857
'Cracked gasoline' 'Premium Gasoline' 7 68.6736
'Cracked gasoline' 'Premium Gasoline' 8 0
'Cracked gasoline' 'Premium Gasoline' 9 0
'Cracked gasoline' 'Premium Gasoline' 10 229.261
'Cracked gasoline' 'Premium Gasoline' 11 3.92764e-12
'Cracked gasoline' 'Premium Gasoline' 12 429.469
'Cracked gasoline' 'Regular Gasoline' 1 0
'Cracked gasoline' 'Regular Gasoline' 2 0
'Cracked gasoline' 'Regular Gasoline' 3 0
'Cracked gasoline' 'Regular Gasoline' 4 296.319
'Cracked gasoline' 'Regular Gasoline' 5 339.291
'Cracked gasoline' 'Regular Gasoline' 6 0
'Cracked gasoline' 'Regular Gasoline' 7 709.889
'Cracked gasoline' 'Regular Gasoline' 8 553.907
'Cracked gasoline' 'Regular Gasoline' 9 553.907
'Cracked gasoline' 'Regular Gasoline' 10 0
'Cracked gasoline' 'Regular Gasoline' 11 312.859
'Cracked gasoline' 'Regular Gasoline' 12 0
'Heavy Naphta' 'Premium Gasoline' 1 1483.19
'Heavy Naphta' 'Premium Gasoline' 2 0
'Heavy Naphta' 'Premium Gasoline' 3 0
'Heavy Naphta' 'Premium Gasoline' 4 0
'Heavy Naphta' 'Premium Gasoline' 5 0
'Heavy Naphta' 'Premium Gasoline' 6 1353.18
'Heavy Naphta' 'Premium Gasoline' 7 0
'Heavy Naphta' 'Premium Gasoline' 8 0
'Heavy Naphta' 'Premium Gasoline' 9 0
'Heavy Naphta' 'Premium Gasoline' 10 0
'Heavy Naphta' 'Premium Gasoline' 11 0
'Heavy Naphta' 'Premium Gasoline' 12 1034.1
'Heavy Naphta' 'Regular Gasoline' 1 0
'Heavy Naphta' 'Regular Gasoline' 2 2758.71
'Heavy Naphta' 'Regular Gasoline' 3 0
'Heavy Naphta' 'Regular Gasoline' 4 541.394
'Heavy Naphta' 'Regular Gasoline' 5 731.602
'Heavy Naphta' 'Regular Gasoline' 6 27.2364
'Heavy Naphta' 'Regular Gasoline' 7 1639.54
'Heavy Naphta' 'Regular Gasoline' 8 1505.32
'Heavy Naphta' 'Regular Gasoline' 9 1252.91
'Heavy Naphta' 'Regular Gasoline' 10 934.749
'Heavy Naphta' 'Regular Gasoline' 11 894.134
'Heavy Naphta' 'Regular Gasoline' 12 0
'Heavy Oil' 'Fuel Oil' 1 728.984
'Heavy Oil' 'Fuel Oil' 2 1327.27
'Heavy Oil' 'Fuel Oil' 3 0
'Heavy Oil' 'Fuel Oil' 4 392.187
'Heavy Oil' 'Fuel Oil' 5 449.061
'Heavy Oil' 'Fuel Oil' 6 415.714
'Heavy Oil' 'Fuel Oil' 7 458.434
'Heavy Oil' 'Fuel Oil' 8 649.47
'Heavy Oil' 'Fuel Oil' 9 649.47
'Heavy Oil' 'Fuel Oil' 10 303.434
'Heavy Oil' 'Fuel Oil' 11 390.357
'Heavy Oil' 'Fuel Oil' 12 511.12
'Heavy Oil' 'Jet Fuel' 1 3137.79
'Heavy Oil' 'Jet Fuel' 2 6369.43
'Heavy Oil' 'Jet Fuel' 3 0
'Heavy Oil' 'Jet Fuel' 4 4782.5
'Heavy Oil' 'Jet Fuel' 5 6119.18
'Heavy Oil' 'Jet Fuel' 6 5284.29
'Heavy Oil' 'Jet Fuel' 7 3823.56
'Heavy Oil' 'Jet Fuel' 8 3656.49
'Heavy Oil' 'Jet Fuel' 9 3656.49
'Heavy Oil' 'Jet Fuel' 10 4573.39
'Heavy Oil' 'Jet Fuel' 11 3551.09
'Heavy Oil' 'Jet Fuel' 12 3312.41
'Light Naphta' 'Premium Gasoline' 1 419.932
'Light Naphta' 'Premium Gasoline' 2 0
'Light Naphta' 'Premium Gasoline' 3 0
'Light Naphta' 'Premium Gasoline' 4 4085.28
'Light Naphta' 'Premium Gasoline' 5 4934.12
'Light Naphta' 'Premium Gasoline' 6 0
'Light Naphta' 'Premium Gasoline' 7 0
'Light Naphta' 'Premium Gasoline' 8 3822.88
'Light Naphta' 'Premium Gasoline' 9 4435.2
'Light Naphta' 'Premium Gasoline' 10 3604.3
'Light Naphta' 'Premium Gasoline' 11 3326.4
'Light Naphta' 'Premium Gasoline' 12 1662.84
'Light Naphta' 'Regular Gasoline' 1 2594.1
'Light Naphta' 'Regular Gasoline' 2 6084.76
'Light Naphta' 'Regular Gasoline' 3 0
'Light Naphta' 'Regular Gasoline' 4 0
'Light Naphta' 'Regular Gasoline' 5 0
'Light Naphta' 'Regular Gasoline' 6 4500
'Light Naphta' 'Regular Gasoline' 7 4500
'Light Naphta' 'Regular Gasoline' 8 677.119
'Light Naphta' 'Regular Gasoline' 9 64.8
'Light Naphta' 'Regular Gasoline' 10 245.829
'Light Naphta' 'Regular Gasoline' 11 97.3843
'Light Naphta' 'Regular Gasoline' 12 2109.62
'Light Oil' 'Fuel Oil' 1 2429.95
'Light Oil' 'Fuel Oil' 2 4424.23
'Light Oil' 'Fuel Oil' 3 0
'Light Oil' 'Fuel Oil' 4 1307.29
'Light Oil' 'Fuel Oil' 5 1496.87
'Light Oil' 'Fuel Oil' 6 1385.71
'Light Oil' 'Fuel Oil' 7 1528.11
'Light Oil' 'Fuel Oil' 8 2164.9
'Light Oil' 'Fuel Oil' 9 2164.9
'Light Oil' 'Fuel Oil' 10 1011.45
'Light Oil' 'Fuel Oil' 11 1301.19
'Light Oil' 'Fuel Oil' 12 1703.73
'Light Oil' 'Jet Fuel' 1 0
'Light Oil' 'Jet Fuel' 2 0
'Light Oil' 'Jet Fuel' 3 0
'Light Oil' 'Jet Fuel' 4 0
'Light Oil' 'Jet Fuel' 5 426.158
'Light Oil' 'Jet Fuel' 6 0
'Light Oil' 'Jet Fuel' 7 0
'Light Oil' 'Jet Fuel' 8 0
'Light Oil' 'Jet Fuel' 9 0
'Light Oil' 'Jet Fuel' 10 367.655
'Light Oil' 'Jet Fuel' 11 0
'Light Oil' 'Jet Fuel' 12 0
'Lube Oil' 'Lube Oil' 1 0
'Lube Oil' 'Lube Oil' 2 0
'Lube Oil' 'Lube Oil' 3 0
'Lube Oil' 'Lube Oil' 4 0
'Lube Oil' 'Lube Oil' 5 0
'Lube Oil' 'Lube Oil' 6 0
'Lube Oil' 'Lube Oil' 7 0
'Lube Oil' 'Lube Oil' 8 0
'Lube Oil' 'Lube Oil' 9 0
'Lube Oil' 'Lube Oil' 10 0
'Lube Oil' 'Lube Oil' 11 0
'Lube Oil' 'Lube Oil' 12 0
'Medium Naphta' 'Premium Gasoline' 1 0
'Medium Naphta' 'Premium Gasoline' 2 4445.34
'Medium Naphta' 'Premium Gasoline' 3 0
'Medium Naphta' 'Premium Gasoline' 4 730.572
'Medium Naphta' 'Premium Gasoline' 5 999.604
'Medium Naphta' 'Premium Gasoline' 6 845.327
'Medium Naphta' 'Premium Gasoline' 7 2761.49
'Medium Naphta' 'Premium Gasoline' 8 0
'Medium Naphta' 'Premium Gasoline' 9 0
'Medium Naphta' 'Premium Gasoline' 10 0
'Medium Naphta' 'Premium Gasoline' 11 0
'Medium Naphta' 'Premium Gasoline' 12 0
'Medium Naphta' 'Regular Gasoline' 1 4772.22
'Medium Naphta' 'Regular Gasoline' 2 5357.12
'Medium Naphta' 'Regular Gasoline' 3 0
'Medium Naphta' 'Regular Gasoline' 4 6078.23
'Medium Naphta' 'Regular Gasoline' 5 7368.63
'Medium Naphta' 'Regular Gasoline' 6 6654.67
'Medium Naphta' 'Regular Gasoline' 7 4738.51
'Medium Naphta' 'Regular Gasoline' 8 7500
'Medium Naphta' 'Regular Gasoline' 9 7500
'Medium Naphta' 'Regular Gasoline' 10 6416.87
'Medium Naphta' 'Regular Gasoline' 11 5706.31
'Medium Naphta' 'Regular Gasoline' 12 6287.42
'Reformed gasoline' 'Premium Gasoline' 1 1465.05
'Reformed gasoline' 'Premium Gasoline' 2 2401.34
'Reformed gasoline' 'Premium Gasoline' 3 0
'Reformed gasoline' 'Premium Gasoline' 4 1265.2
'Reformed gasoline' 'Premium Gasoline' 5 1606.23
'Reformed gasoline' 'Premium Gasoline' 6 1929.4
'Reformed gasoline' 'Premium Gasoline' 7 1805.02
'Reformed gasoline' 'Premium Gasoline' 8 728.168
'Reformed gasoline' 'Premium Gasoline' 9 844.8
'Reformed gasoline' 'Premium Gasoline' 10 566.443
'Reformed gasoline' 'Premium Gasoline' 11 633.6
'Reformed gasoline' 'Premium Gasoline' 12 1273.6
'Reformed gasoline' 'Regular Gasoline' 1 113.686
'Reformed gasoline' 'Regular Gasoline' 2 759.413
'Reformed gasoline' 'Regular Gasoline' 3 0
'Reformed gasoline' 'Regular Gasoline' 4 828.056
'Reformed gasoline' 'Regular Gasoline' 5 1051.35
'Reformed gasoline' 'Regular Gasoline' 6 0
'Reformed gasoline' 'Regular Gasoline' 7 0
'Reformed gasoline' 'Regular Gasoline' 8 1141.28
'Reformed gasoline' 'Regular Gasoline' 9 1145.8
'Reformed gasoline' 'Regular Gasoline' 10 1202.55
'Reformed gasoline' 'Regular Gasoline' 11 909.315
'Reformed gasoline' 'Regular Gasoline' 12 402.967
Residuum 'Fuel Oil' 1 242.995
Residuum 'Fuel Oil' 2 442.423
Residuum 'Fuel Oil' 3 0
Residuum 'Fuel Oil' 4 130.729
Residuum 'Fuel Oil' 5 149.687
Residuum 'Fuel Oil' 6 138.571
Residuum 'Fuel Oil' 7 152.811
Residuum 'Fuel Oil' 8 216.49
Residuum 'Fuel Oil' 9 216.49
Residuum 'Fuel Oil' 10 101.145
Residuum 'Fuel Oil' 11 130.119
Residuum 'Fuel Oil' 12 170.373
Residuum 'Jet Fuel' 1 3022.21
Residuum 'Jet Fuel' 2 5950.57
Residuum 'Jet Fuel' 3 0
Residuum 'Jet Fuel' 4 3137.5
Residuum 'Jet Fuel' 5 4014.67
Residuum 'Jet Fuel' 6 3461.43
Residuum 'Jet Fuel' 7 3447.19
Residuum 'Jet Fuel' 8 3383.51
Residuum 'Jet Fuel' 9 3383.51
Residuum 'Jet Fuel' 10 2978.95
Residuum 'Jet Fuel' 11 2608.91
Residuum 'Jet Fuel' 12 2847.59
;
: OctaneNumberMin VaporPressure_Max Storage_Fraction :=
'Fuel Oil' 1 . . 568.165
'Fuel Oil' 2 . . 4878.24
'Fuel Oil' 3 . . 1304.34
'Fuel Oil' 4 . . 60.0276
'Fuel Oil' 5 . . 5.91172e-12
'Fuel Oil' 6 . . 118.093
'Fuel Oil' 7 . . 489.94
'Fuel Oil' 8 . . 1714.39
'Fuel Oil' 9 . . 2468.6
'Fuel Oil' 10 . . 1073.29
'Fuel Oil' 11 . . 100.265
'Fuel Oil' 12 . . 3.68345e-11
'Jet Fuel' 1 . 0 0
'Jet Fuel' 2 . 0 6098.4
'Jet Fuel' 3 . 0 -1.81899e-12
'Jet Fuel' 4 . 0 -9.09495e-13
'Jet Fuel' 5 . 0 -1.81899e-12
'Jet Fuel' 6 . 0 1.27329e-11
'Jet Fuel' 7 . 0 -2.63753e-11
'Jet Fuel' 8 . 0 -1.36424e-11
'Jet Fuel' 9 . 0 -1.45519e-11
'Jet Fuel' 10 . 0 -1.90994e-11
'Jet Fuel' 11 . 0 -1.66892e-11
'Jet Fuel' 12 . 0 -4.09273e-11
'Lube Oil' 1 . . 0
'Lube Oil' 2 . . 0
'Lube Oil' 3 . . 0
'Lube Oil' 4 . . 0
'Lube Oil' 5 . . 0
'Lube Oil' 6 . . 0
'Lube Oil' 7 . . 0
'Lube Oil' 8 . . 0
'Lube Oil' 9 . . 0
'Lube Oil' 10 . . 0
'Lube Oil' 11 . . 0
'Lube Oil' 12 . . 0
'Premium Gasoline' 1 0 . -4.54747e-13
'Premium Gasoline' 2 0 . 3912.48
'Premium Gasoline' 3 0 . 2.72848e-12
'Premium Gasoline' 4 0 . 2095.6
'Premium Gasoline' 5 0 . 5197.88
'Premium Gasoline' 6 0 . 3530.89
'Premium Gasoline' 7 0 . 1589.64
'Premium Gasoline' 8 0 . 6.36646e-12
'Premium Gasoline' 9 0 . 1.18234e-11
'Premium Gasoline' 10 0 . -5.45697e-12
'Premium Gasoline' 11 0 . 4.09273e-12
'Premium Gasoline' 12 0 . -2.72848e-12
'Regular Gasoline' 1 . . 0
'Regular Gasoline' 2 . . 7330.4
'Regular Gasoline' 3 . . -5.45697e-12
'Regular Gasoline' 4 . . -9.09495e-13
'Regular Gasoline' 5 . . 1366.98
'Regular Gasoline' 6 . . 682.848
'Regular Gasoline' 7 . . -7.27596e-12
'Regular Gasoline' 8 . . -1.09139e-11
'Regular Gasoline' 9 . . 1.09139e-11
'Regular Gasoline' 10 . . -9.09495e-12
'Regular Gasoline' 11 . . 5.00222e-11
'Regular Gasoline' 12 . . 2.18279e-11
;
Demand ['Fuel Oil',Station1,*,*]
: 1 2 3 4 5 6 :=
1 0 3800 0 0 0 0
2 0 3610 0 0 0 0
3 -4.54747e-13 3610 0 0 0 0
4 -4.54747e-13 3610 0 0 0 0
5 0 2755 0 0 0 0
6 0 2375 -3.49437e-11 0 0 0
7 0 2375 0 0 0 0
8 0 2660 0 0 0 0
9 0 3135 0 0 0 0
10 0 3230 0 0 0 0
11 0 3325 0 0 0 0
12 3168 0 0 0 0 0
['Jet Fuel',Station1,*,*]
: 1 2 3 4 5 6 :=
1 6160 0 0 0 0 0
2 6160 0 0 0 0 0
3 6160 0 0 0 0 0
4 7920 0 0 0 0 0
5 10560 0 0 0 0 0
6 8800 0 0 0 0 0
7 7920 0 0 0 0 0
8 7040 0 0 0 0 0
9 7040 0 0 0 0 0
10 7920 0 0 0 0 0
11 6160 -3.18323e-11 0 0 0 0
12 6160 0 0 0 0 0
['Lube Oil',Station1,*,*]
: 1 2 3 4 5 6 :=
1 0 0 0 0 0 0
2 0 0 0 0 0 0
3 0 0 0 0 0 0
4 0 0 0 0 0 0
5 0 0 0 0 0 0
6 0 0 0 0 0 0
7 0 0 0 0 0 0
8 0 0 0 0 0 0
9 0 0 0 0 0 0
10 0 0 0 0 0 0
11 0 0 0 0 0 0
12 0 0 0 0 0 0
['Premium Gasoline',Station1,*,*]
: 1 2 3 4 5 6 :=
1 3960 0 0 0 0 0
2 3960 0 0 0 0 0
3 3960 0 0 0 0 0
4 3960 0 0 0 0 0
5 4400 0 0 0 0 0
6 6160 0 0 0 0 0
7 6600 0 0 0 0 0
8 6160 0 0 0 0 0
9 5280 0 0 0 0 0
10 4400 0 0 0 0 0
11 3960 0 0 0 0 0
12 4400 0 0 0 0 0
['Regular Gasoline',Station1,*,*]
: 1 2 3 4 5 6 :=
1 7480 0 0 0 0 0
2 7480 0 0 0 0 0
3 7480 0 0 0 0 0
4 7744 0 0 0 0 0
5 8096 0 0 0 0 0
6 11880 0 0 0 0 0
7 12284.7 0 0 0 0 0
8 11377.6 0 0 0 0 0
9 10517.4 0 0 0 0 0
10 8800 0 0 0 0 0
11 7920 0 0 0 0 0
12 8800 0 0 0 0 0
;
: Loan_In Loan_Out :=
I 1 0 .
I 2 194710 0
I 3 0 195765
I 4 0 0
I 5 0 0
I 6 0 0
I 7 0 0
I 8 0 0
I 9 0 0
I 10 0 0
I 11 0 0
I 12 . 0
;
CashFlow [*] :=
1 232094
2 -2312090
3 2481690
4 78728.1
5 -433610
6 585397
7 615940
8 386024
9 197119
10 400867
11 251837
12 160251
;
Waste_Pollutant [*,*] (tr)
: Hydrocarbon 'Sulfur dioxide' :=
1 269077 385681
2 511614 734160
3 0 0
4 250804 371779
5 324924 480952
6 248116 361996
7 267436 392203
8 267234 392757
9 276422 408244
10 219856 322741
11 200985 295620
12 228633 337255
;
Octane number for products: 1 Fuel Oil 0.00
Octane number for products: 2 Fuel Oil 0.00
Octane number for products: 3 Fuel Oil 0.00
Octane number for products: 4 Fuel Oil 0.00
Octane number for products: 5 Fuel Oil 0.00
Octane number for products: 6 Fuel Oil 0.00
Octane number for products: 7 Fuel Oil 0.00
Octane number for products: 8 Fuel Oil 0.00
Octane number for products: 9 Fuel Oil 0.00
Octane number for products: 10 Fuel Oil 0.00
Octane number for products: 11 Fuel Oil 0.00
Octane number for products: 12 Fuel Oil 0.00
Octane number for products: 1 Lube Oil 0.00
Octane number for products: 2 Lube Oil 0.00
Octane number for products: 3 Lube Oil 0.00
Octane number for products: 4 Lube Oil 0.00
Octane number for products: 5 Lube Oil 0.00
Octane number for products: 6 Lube Oil 0.00
Octane number for products: 7 Lube Oil 0.00
Octane number for products: 8 Lube Oil 0.00
Octane number for products: 9 Lube Oil 0.00
Octane number for products: 10 Lube Oil 0.00
Octane number for products: 11 Lube Oil 0.00
Octane number for products: 12 Lube Oil 0.00
Octane number for products: 1 Premium Gasoline 93.98
Octane number for products: 2 Premium Gasoline 93.98
Octane number for products: 3 Premium Gasoline 0.00
Octane number for products: 4 Premium Gasoline 93.97
Octane number for products: 5 Premium Gasoline 93.98
Octane number for products: 6 Premium Gasoline 93.98
Octane number for products: 7 Premium Gasoline 93.96
Octane number for products: 8 Premium Gasoline 93.94
Octane number for products: 9 Premium Gasoline 93.95
Octane number for products: 10 Premium Gasoline 93.96
Octane number for products: 11 Premium Gasoline 93.95
Octane number for products: 12 Premium Gasoline 93.98
Octane number for products: 1 Jet Fuel 0.00
Octane number for products: 2 Jet Fuel 0.00
Octane number for products: 3 Jet Fuel 0.00
Octane number for products: 4 Jet Fuel 0.00
Octane number for products: 5 Jet Fuel 0.00
Octane number for products: 6 Jet Fuel 0.00
Octane number for products: 7 Jet Fuel 0.00
Octane number for products: 8 Jet Fuel 0.00
Octane number for products: 9 Jet Fuel 0.00
Octane number for products: 10 Jet Fuel 0.00
Octane number for products: 11 Jet Fuel 0.00
Octane number for products: 12 Jet Fuel 0.00
Octane number for products: 1 Regular Gasoline 83.98
Octane number for products: 2 Regular Gasoline 83.99
Octane number for products: 3 Regular Gasoline 0.00
Octane number for products: 4 Regular Gasoline 83.99
Octane number for products: 5 Regular Gasoline 83.99
Octane number for products: 6 Regular Gasoline 83.98
Octane number for products: 7 Regular Gasoline 83.99
Octane number for products: 8 Regular Gasoline 84.00
Octane number for products: 9 Regular Gasoline 84.00
Octane number for products: 10 Regular Gasoline 83.99
Octane number for products: 11 Regular Gasoline 84.00
Octane number for products: 12 Regular Gasoline 83.98
Premium / Regular percentage: 1 0.53
Premium / Regular percentage: 2 0.53
Premium / Regular percentage: 3 0.00
Premium / Regular percentage: 4 0.79
Premium / Regular percentage: 5 0.79
Premium / Regular percentage: 6 0.40
Premium / Regular percentage: 7 0.40
Premium / Regular percentage: 8 0.40
Premium / Regular percentage: 9 0.50
Premium / Regular percentage: 10 0.50
Premium / Regular percentage: 11 0.50
Premium / Regular percentage: 12 0.50
Production Fuel Oil ratio: 1 Cracked Oil 4.00
Production Fuel Oil ratio: 2 Cracked Oil 4.00
Production Fuel Oil ratio: 3 Cracked Oil 0.00
Production Fuel Oil ratio: 4 Cracked Oil 4.00
Production Fuel Oil ratio: 5 Cracked Oil 4.00
Production Fuel Oil ratio: 6 Cracked Oil 4.00
Production Fuel Oil ratio: 7 Cracked Oil 4.00
Production Fuel Oil ratio: 8 Cracked Oil 4.00
Production Fuel Oil ratio: 9 Cracked Oil 4.00
Production Fuel Oil ratio: 10 Cracked Oil 4.00
Production Fuel Oil ratio: 11 Cracked Oil 4.00
Production Fuel Oil ratio: 12 Cracked Oil 4.00
Production Fuel Oil ratio: 1 Heavy Oil 3.00
Production Fuel Oil ratio: 2 Heavy Oil 3.00
Production Fuel Oil ratio: 3 Heavy Oil 0.00
Production Fuel Oil ratio: 4 Heavy Oil 3.00
Production Fuel Oil ratio: 5 Heavy Oil 3.00
Production Fuel Oil ratio: 6 Heavy Oil 3.00
Production Fuel Oil ratio: 7 Heavy Oil 3.00
Production Fuel Oil ratio: 8 Heavy Oil 3.00
Production Fuel Oil ratio: 9 Heavy Oil 3.00
Production Fuel Oil ratio: 10 Heavy Oil 3.00
Production Fuel Oil ratio: 11 Heavy Oil 3.00
Production Fuel Oil ratio: 12 Heavy Oil 3.00
Production Fuel Oil ratio: 1 Light Oil 10.00
Production Fuel Oil ratio: 2 Light Oil 10.00
Production Fuel Oil ratio: 3 Light Oil 0.00
Production Fuel Oil ratio: 4 Light Oil 10.00
Production Fuel Oil ratio: 5 Light Oil 10.00
Production Fuel Oil ratio: 6 Light Oil 10.00
Production Fuel Oil ratio: 7 Light Oil 10.00
Production Fuel Oil ratio: 8 Light Oil 10.00
Production Fuel Oil ratio: 9 Light Oil 10.00
Production Fuel Oil ratio: 10 Light Oil 10.00
Production Fuel Oil ratio: 11 Light Oil 10.00
Production Fuel Oil ratio: 12 Light Oil 10.00
Production Fuel Oil ratio: 1 Residuum 1.00
Production Fuel Oil ratio: 2 Residuum 1.00
Production Fuel Oil ratio: 3 Residuum 0.00
Production Fuel Oil ratio: 4 Residuum 1.00
Production Fuel Oil ratio: 5 Residuum 1.00
Production Fuel Oil ratio: 6 Residuum 1.00
Production Fuel Oil ratio: 7 Residuum 1.00
Production Fuel Oil ratio: 8 Residuum 1.00
Production Fuel Oil ratio: 9 Residuum 1.00
Production Fuel Oil ratio: 10 Residuum 1.00
Production Fuel Oil ratio: 11 Residuum 1.00
Production Fuel Oil ratio: 12 Residuum 1.00
8. Further steps#
Verify Solution Accuracy
Check Constraints
Validate Assumptions
Cross-Check with Historical Data
Sensitivity Analysis
Analyze how changes in key parameters (e.g., crude oil prices, demand forecasts) affect the solution
Scenario Analysis
Evaluate the solution under different scenarios (e.g., market fluctuations, supply disruptions)
Risk Management
Identify Potential Risks: Operational, Market, External
Monitoring and Feedback
Implementation Monitoring
Continuous Improvement
Review and Update
Post-Implementation Review