0% found this document useful (0 votes)
78 views35 pages

GAMS Workshop With Formulation

This document summarizes a workshop on formulating and solving different types of optimization problems using GAMS. The workshop covers linear programming (LP), mixed integer linear programming (MILP), nonlinear programming (NLP), and mixed integer nonlinear programming (MINLP). It provides examples of how to model LP, MILP, NLP and MINLP problems in GAMS and interpret results. The document includes formulations for sample refinery scheduling and chemical complex design problems.

Uploaded by

Ahmed Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views35 pages

GAMS Workshop With Formulation

This document summarizes a workshop on formulating and solving different types of optimization problems using GAMS. The workshop covers linear programming (LP), mixed integer linear programming (MILP), nonlinear programming (NLP), and mixed integer nonlinear programming (MINLP). It provides examples of how to model LP, MILP, NLP and MINLP problems in GAMS and interpret results. The document includes formulations for sample refinery scheduling and chemical complex design problems.

Uploaded by

Ahmed Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Workshop on LP, NLP, MILP, and MINLP

using GAMS
Rofice Dickson

Department of Chemistry and Chemical Engineering


Lahore University of Management & Sciences, Pakistan
Lecture content
• How to formulate and solve different optimization problems in GAMS

• How to interpret results from GAMS

• Solutions to avoid difficulties associated with nonlinear and mixed integer


nonlinear optimization problems

• Sensitivity analysis (if time allows)

• Summary

2 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


What are the key characteristics
of optimization problem?

3 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Problems Types

LP : Linear Programming
MILP : Mixed integer LP
NLP : Nonlinear Programming
MINLP : Mixed Integer NLP

4 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Formulating the optimization
problem

max 𝑧 = 𝑓(𝑥, 𝑦) (1)

𝑠. 𝑡. 𝑔 𝑥, 𝑦 ≥ 0 (2)

ℎ 𝑥, 𝑦 = 0, (3)

𝑥 𝐿𝑂 ≤ 𝑥 ≤ 𝑥 𝑈𝑃 (4)
𝑛 (5)
𝑥 ∈ 𝑋, 𝑦 ∈ 0, 1

5 Department of Chemistry and Chemical Engineering, LUMS 2/17/2022


Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson
Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson
Exercise 1: Refinery scheduling (Problem
type: LP)
A refinery can use four different crudes to produce gasoline,
heating oil, jet fuel and lube oil. The crude supplies are limited,
and maximum product demands are known. A schematic of the
processing operation is given in Fig. 1. Products yields depend on
the crude oil and the process. Operating and purchase costs of
crudes along with the sale prices of the products are given in Table
1. Formulate the problem for scheduling the refinery so as
maximize the profit.

8 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Processing operation

Gasoline
1

2 Fuel Chain Heating oil

3
Jet Fuel

Lube
4 Lube oil
Chain

9 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Problem data

Product Yields bbl/bbl crude


Product Maximum
Products/Crudes Fuel Process Lube value Demand
($/bbl) kbbl/wk
1 2 3 4 4
Gasoline 0.6 0.5 0.3 0.4 0.4 45.00 170
Heating Oil 0.2 0.2 0.3 0.3 0.1 30.00 85
Jet Fuel 0.1 0.2 0.3 0.2 0.2 15.00 85
Lube Oil 0.0 0.0 0.0 0.0 0.2 60.00 20
Operating Losses 0.1 0.1 0.1 0.1 0.1 - -
Crude cost ($/bbl) 15.00 15.00 15.00 25.00 25.00
Operating cost
5.00 8.50 7.50 3.00 2.50
($/bbl)
Crude supply 200
100 100 100
(kbbl/wk)

10 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Formulation
Constraints:
Production(p) = σ𝑐 crude_oil(c) ∗ Yield(p,c) (1)

Revenues(p) = Production(p) *sales(p) (2)

Operating_costs(c) = crude_oil(c) * tcost(c) (3)

Production(p) =l= demand(p) (4)

crude_oil(c) =l= supply(c) (5)

Objective function:

Max Profit = σ𝑝 Revenues(𝑝) – σ𝑐 Operating_costs(𝑐)

There are nineteen optimization variables in the above formulation. All are
continuous variables. The objective function is a linear function of these
variables, and so are Eqs. 1 and 5, therefore this is a linear programming
(LP) formulation.
11 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022
Suggested Exercises
1) What happens if the maximum demand for gasoline is
increased from 170 to 200 kbbl/wk?

2) What happen if only 75 kkbl/week of crude 1 is available?

3) Formulate and solve the problem to schedule the refinery for


minimum cost operation if given maximum product demands
are changed to be the minimum requirements.

12 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Exercise 2: Design of a Chemical Complex
(Problem type: MILP)
Problem statement

A company is considering to produce a chemical C which can be


manufactured with either process II or process III, both of which
use as raw material chemical B. B can be purchased from another
company or else manufactured with process I which uses A as a
raw material. Given the specification below, decide:

a) Should chemical C be produced, and if so, how much?

b) Which process to build (II and III are exclusive)?

c) How to obtain chemical B?

The objective is to maximize profit.

13 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Proposed Chemical Complex

14 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Data
Investment and operating costs:
Fixed ($/hr) Variable ($/ton raw material)
Process I 1000 250
Process II 1500 400
Process III 2000 550
Prices:
A: 500 $/ton
B: 950 $/ton
C: 1800 $/ton
Conversion:
Process I: 90% of A to B
Process II: 82% of B to C
Process III: 95% of B to C
Market Constraints:
Maximum supply of A: 16 tons/hr
Maximum demand of C: 10 tons/hr

15 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Formulation
The main question is which of processes I, II, and III to select if is
profitable to produce C. In that case, we also need to find the
optimal operating conditions of the selected processes, and to
decide on the appropriate levels of purchases of the raw materials
A and B, and sales of the product C.
There are several discrete decisions involved in this problem:
a) For each one of the three processes: to build or not to build
the process
b) Processes II and III are mutually exclusive. This creates the
need for modelling a logical constraint that if process II is
selected, then process III should not be selected and vice
versa.
c) In addition to a cost which is proportional to the size of the
installed process, a fixed charge is to be paid for investments.
This fixed charge is incurred if a process is selected and is
independent of how small or big the process is.
16 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022
Cont’d
Model variables
Binary variables:
YI = 1 if process I is selected and 0 if not;
YII = 1 if process II is selected and 0 if not;
YIII = 1 if process III is selected and 0 if not;
Continuous variables:
PA purchase of A (tons/hr)
PB purchase of B (tons/hr)
SC sales of C (tons/hr)
BI production rate of B in process I (tons/hr)
BII consumption rate of B in process II (tons/hr)
BIII consumption rate of B in process III (tons/hr)
CII production rate of C in process II (tons/hr)
CIII production rate of C in process III (tons/hr)

17 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Model Formulation
Logical constraint to select one process:
𝑌𝐼𝐼 + 𝑌𝐼𝐼𝐼 ≤ 1 (1)
Mass balance for chemicals B and C:
BI + 𝑃𝐵 = 𝐵𝐼𝐼 + 𝐵𝐼𝐼𝐼 (2)
CII + CIII = SC (3)
Mass balance around process I, II, and III:
BI = 0.9 PA (4)
CII = 0.82 BII (5)
CIII = 0.95 BIII (6)
To express the condition that a process may not operates unless it is built,
we use the following constraints:
PA ≤ 16 Y1 (7)
BII ≤ (10/0.82) YII (8)
BIII ≤ (10/0.95) YIII (9)
Sales of C may not exceed 10 tons/hr can be modeled as:
SC ≤ 10 (10)
Objective function:
Profit = 1800 SC – (1000 YI +250 PA+15000 YII+400 BII+2000 YIII+550 BIII) –
500 PA – 950 PB (11)
18 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022
Suggested exercise
• Consider the above problem with the following changes:

Maximum demand of C is 15 tons/hr; the selling price for the first


10 tons/hr is 1800 $/ton, and 1500$/ton for the excess

19 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Exercise 3: Problem type (NLP)

20 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Exercise 4: Optimal Selection of Processes
(Problem type: MINLP)
It is proposed to manufacture a chemical C with a process I that
uses raw material B. B can either be purchased and/or
manufactured with two processes, II or III, both of which use
Chemical A as a raw material. Data and specifications for this
problem, in which several nonlinear input-output relations are
given for mass balances, are given in next slides. In order to
decide the optimal selection of processes and levels of production
that maximize profit formulae the MINLP problem and solve with
DICOPT.

21 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Data
Investment and operating costs:
Fixed (103 $/hr) Variable (103 $/ton raw material)
Process I 3.5 2
Process II 1500 1 1
Process III 1.5 1.2
Prices:
A: 1800 $/ton
B: 7000 $/ton
C: 13000 $/ton
Conversions:
Process I: C = 0.90 B
Process II: B = ln(1+A)
Process III: B= 1.2ln(1+A)
Market Constraints:
Maximum capacity of Process I, II, & III: 2 ton/hr of C, 5 ton/hr of B, & 4 ton/hr of B
Maximum demand of C: 1 ton/hr

22 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Diagram for alternative processes
(Superstructure

Note that possible alternatives for this problem include the following: install
only process I and purchase chemical B: install process I and either
process II and/or II with or without purchase of B: and finally, do not
install any of the 3 processes

23 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Cont’d
Model variables
Binary variables:
YI = 1 if process I is selected and 0 if not;
YII = 1 if process II is selected and 0 if not;
YIII = 1 if process III is selected and 0 if not;
Continuous variables:
PA purchase of A (tons/hr)
CI production rate of C (tons/hr)
AII consumption rate of A in process II (tons/hr)
AIII consumption rate of A in process III (tons/hr)
BI consumption of chemical B in process I
BII production rate of B in process II (tons/hr)
BIII production rate of B in process III (tons/hr)
BP purchase of B (tons/hr)

24 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Formulation

25 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Solution

26 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Suggested exercises
• Determine how the optimal configuration will change if: (a) the price of C
drops to 11,000 $/ton, (b) the price of B drops to 5,000 $/ton.

• Assume that the production of the selected process can exceed the
demand of 1 ton/hr of product C. However, the production of up to 1
ton/hr can be sold at $13,000 $/ton, while the excess above this amount
can only be sold at 10,000 $/ton. Modify the MINLP model to predict the
optimal solutions for this case.

27 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Power generation via Fuel oil (Problem type:
NLP)
• A two-boiler turbine combination (Fig. 1) is used to produce a power of
50 MW. It can use any combination of fuel oil and blast furnace gas
(BFG). However only 10 fuel units per hour of BFG is available. Since
this supply of BFG may not be sufficient for the required power
generation, fuel oil must be purchased and used. It is desired that we
can use minimum total amount of fuel oil in the two generators.
• Fuel requirements for the generators can be modelled as:
𝑓 = 𝑎0 + 𝑎1 𝑥 + 𝑎3 𝑥 2
Where f= ton/hr for fuel and unit/h for BFG; and x = power in MW

28 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Data

Generator Fuel Type a0 a1 a2


1 Fuel oil 1.4609 0.15186 0.001450
1 BFG 1.5742 0.16310 0.001358
2 Fuel oil 0.8008 0.20310 0.000916
2 BFG 0.7266 0.22560 0.000778

Generator Maximum power Minimum power


output of generators output of generators

1 18 30
2 14 25

Maximum supply of BFG = 10 units per hour


Total power required = 50 MW
Objective function = Minimize purchase of fuel oil

29 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Formulation
Required power
σ𝑔 𝑃 ≥ 50 (1)
Power generated by individual generators
𝑃 𝐺 = σ𝑓 𝑋(𝑔, 𝑓) (2)
Fuel usage must not exceed purchase
Z 𝑓 = σ(𝑘,𝑔) 𝑎(𝑔, 𝑓, 𝑘) × 𝑥(𝑔, 𝑓)𝑜𝑟𝑑 𝑘 −1
(3)
Objective function (amount of oil purchased to be minimized)
Obj = Z(“oil”) (4)

Model variables
P(G) Total power output of generators in MW
X(G, F) Power outputs of generators from specific fuels
Z(F) Total Amounts of fuel purchased
Obj objective function

30 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson
Solution to avoid difficulties associated with
NLP and MINLP optimization problems

32 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


33 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022
Cont’d
• If possible, convert MINLP to MIP by

✓ Linearization

✓ approximation

34 Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson 2/17/2022


Department of Chemistry and Chemical Engineering, LUMS Rofice Dickson

You might also like