1 CHAPTER ONE INTRODUCTION 1.1 Background Linear programming is the most often used method for solving optimization problems. Since the development of the simplex algorithm for solving linear programming by George Dantzig, Linear programming has been used to solve optimization problems in fields as diverse as petroleum, banking, education, Product Constraints, Raw Material The problem of solving a system of linear inequalities dates back at least as far as Fourier, after whom the method of Fourier-Motzkin elimination is named. Linear programming arose as a mathematical model developed during the secondworld war to plan expenditures and returns in order to reduce costs to the army and increase losses to the enemy. It was kept secret until 1947. Postwar, many industries found its use in their daily planning. Limitations, Safety Restrictions, Product Specifications and Material and Energy Balances, and many others. It has a great importance in operation research methods. A useful tool for solving linear programming problems is WHAT’S BEST! Software. This software employs powerful optimization algorithms leading to dramatically reduced solution time of the optimization procedure when the problem contains a large numbers of variables and constraints.
72
Embed
Refinery Blending Problems by Engr. Adefami Olusegun
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
CHAPTER ONE
INTRODUCTION
1.1 Background
Linear programming is the most often used method for solving optimization problems.
Since the development of the simplex algorithm for solving linear programming by George
Dantzig, Linear programming has been used to solve optimization problems in fields as
diverse as petroleum, banking, education, Product Constraints, Raw Material
The problem of solving a system of linear inequalities dates back at least as far as Fourier,
after whom the method of Fourier-Motzkin elimination is named. Linear programming
arose as a mathematical model developed during the secondworld war to plan expenditures
and returns in order to reduce costs to the army and increase losses to the enemy. It was
kept secret until 1947. Postwar, many industries found its use in their daily planning.
Limitations, Safety Restrictions, Product Specifications and Material and Energy Balances,
and many others. It has a great importance in operation research methods. A useful tool for
solving linear programming problems is WHAT’S BEST! Software. This software
employs powerful optimization algorithms leading to dramatically reduced solution time
of the optimization procedure when the problem contains a large numbers of variables and
constraints.
2
1.2 Objective of Study
(1) To develop a software to solve linear programming problems using Visual Studio
2005.
(2) Formulation and Solving Problems in linear programming.
(3) To determine application of linear programming
(4) To compare the program with other software e.g. Excel Solver
1.3 Scope of Work
This study is relevant to process data as well as enterprise data, consisting of commercial
and financial information, are used with the methodologies shown to make decisions in a
timely fashion. This model can be optimized to obtain target levels and price for inter-
refinery transfers, crude oil and product allocations to each refinery, inventory targets,
optimal operating conditions, stream allocations, and blends for each refinery.
1.4 Statement of the problem
(1) Linear programming is applicable only to problems where the constraints
and objective function are linear i.e., where they can be expressed as
equations which represent straight lines. In real life situations, when
constraints or objective functions are not linear, this technique cannot be
used.
(2) Factors such as uncertainty, weather conditions etc. are not taken into
consideration
3
(3) There may not be an integer as the solution, e.g., the number of men
required may be a fraction and the nearest integer may not be the optimal
solution i.e., Linear programming technique may give practical valued
answer which is not desirable
(4) Only one single objective is dealt with while in real life situations, problems
come with multi-objectives.
(5) Parameters are assumed to be constants but in reality they may not be so.
4
CHAPTER TWO
2 RESEARCH METHODOLOGY
2.1 Introduction
Revised simplex method was programmed into Visual Studio 2005 software
through Visual basic application to solve a Linear Programming problem where
optimal solution is determined. This program enables us to solve different problems
in Refinery Blending and in Process chemical industry. The Computer uses linear
Programming models to optimize blending at lowest cost.
2.2 Visual Basic Tools In the Program
The tools used in the program are:
1. TextBox
2. ComboBox
3. Button
4. ListBox
5. Rich TextBox
TEXTBOX -: We used the textbox to display some text that can be edited.
COMBOBOX -: Combox was used to select the type of optimization (either MAXIMIZE
or MINIMIZE).We also used the ComboBox to select the number of variables the objective
function to optimize.
BUTTON-: We used Button to raises an event when clicked. In the program, three buttons
were used which are “EXECUTE”, “CLEAR” & “EXIT”. Any button pressed responds
based on the Click Event code.
5
LISTBOX-: We used it in the program to accept each constrain and display them.
RICH TEXTBOX-: We used rich textbox to display the result of the computation.
6
CHAPTER THREE
3.1 Program Design Strategy:
Every computer program has to follow some strategies before they can be effectively
written. The strategies used in designing this program consist of three stages which are:
1. Planning stage;
2. Interface stage; and
3. Coding stage
Planning Stage
The stage involves the use of flowchart in order to determine the flow and order the
program will follow so as to write the program effectively. One other tool that was used is
algorithm.
The flowchart for this program is as shown in figure 3.1 while the algorithms follow
immediately.
7
Figure 3.1 Program Flow Chart for Design
3.3.1 The Revised Simplex Program Algorithm.
1. Start
2. Choose the number of variable of the objective function
3. Select to either maximize or minimize the function
4. Supply the objective function
5. Supply each of the constrains
Yes
No
Start
Supply the objective function
and constrains and validate
them
Do the Constrains
validates?
Select the No of
objective function
variable
Do the revised simplex computation
Display the output:
Optimal solution
Stop
8
6. Check if the objective function and constrains are correct (validation). If not
correct, go to step 9.
7. Do the revised simplex computation.
8. Display the result.
9. Stop.
The Revised Simplex Algorithm
1. Start with some basic index set B1 = {i(1), i(2), … ,i(m)}.
2. Compute a coefficient of the relative cost coefficient
rj = cj - cBAB-1aj
for B1 until some index j with rj > 0 is found.
(i).If all rj ≤ 0, termination phase has been reached.
(ii).Only those j M N1 are candidates
3. Find AB-1aj = aj and AB-1b = b and compute the allowable ratios of the jth column , viz.,
bi/aij for those I with aij > 0.
(i). If there are no allowable ratios, then a termination phase has been reached.
4. Find an index k where the minimum ratio is attained.
5. Add j to the basic index set and delete i(k) to get a new basic index set B2.
6. Go back to step 2.
Interface Design Stage
This stage involves the designing of the forms used in the program. The forms were first
designed effectively before the code for the action is written. It suffice us here to explain
the program components used in the design of the forms
9
3.2 Program Component
In this program, components used are two window forms (frmSiimplex and frmRetrieve)
and a module (Rsimplex).
3.2.1 A Brief Description:
The “frmSimplex” is the startup form. It allows the user to enter the objective function and
constrains, validate and execute the function. It also allows the user to save the executed
objective function and retrieve the saved equation. The executed function can also be
printed. All these can be achieved by pressing different buttons (Execute, Save, Validate,
Retrieve and Print buttons). It also has “Exit” button which is used to close the program.
The “frmRetrieve” serves as the form that loads when the “Retrieve” button is being
pressed on the “frmSimplex” form. It provide the user the opportunity of choosing from
the formerly saved functions and execute it and get the answer being displayed on the
“frmSimplex” form. It has “Execute” and “Exit” buttons.
The “RSimplex” module contains public variables, many functions and a structure. The
functions are “Determinant”, “FormLU”, “Revised Simplex
The Screen Shot of the following Buttons where display below Execute, Save, Print,
Validate, Retrieve, Clear and Exit.
10
Figure 3.2 Showing “Execute Button”
Figure 3.3 Showing the “Save Button”
11
Figure 3.4 showing “Print Button”
12
Figure 3.5 Showing “Validate Button”
13
Figure 3.6 Showing “Retrieve button” of Revised Simplex
Figure. 3.7 “Clear Button”
14
Figure 3.8 showing the “Exist” button display.
3.3.2. Step by Step Procedure Used to Design The Interface:
For any work to be done effective, orders had to be followed. Consequently, there are
procedures that are followed in the course of writing this program. They are as follows:
1. The program was first planned using flowchart. This was to make writing the
program fast and effective with little bugs.
2. After this, the database used was designed . This is necessary to know the structure
of the database and program accordingly to avoid unnecessary wasting of effort in
adjusting both the program and database in the course of writing the codes.
3. The “frmSimplex” form was later created after the paper work concerning the
program interface had been made.
15
4. The code for the form was written and the bugs (errors) were removed through
testing and debugging the codes.
5. It was later viewed to create allowance for users to have the objective function
saved after the execution. This lead the designing “RSimplex” module and
“frmRetrieve” form.
6. The “RSimplex” module was necessary to store public variables and create public
functions which were used by the two forms.
7. The “frmRetrieve” was then designed and the code was written.
8. The overall program was tested using different examples from textbooks, internet,
and formulated ones.
Coding Stage
This is the stage where the code for the program was written for the form objects designed
in “Interface Design Stage”. These codes are shown below.
CHAPTER FOUR
4 Results and Discussion
16
4.1 Introduction
The software is written in Visual Studio 2005 through Visual basic (VB). Code Visual to
Flowchart is a program Flow chart generator for code flowcharting and visualization. It
can perform automated reverse engineering of program code into programming flowcharts,
help programmers to document, visualize and understand source code.
4.2 DATA USED FOR THE PROJECT
Data for the Refinery Feeds and Products were formulated and analyzed in Problem 4.1
and optimum value was determined. Both Problem 4.2 and Problem 4.3 are Production
Planning problems and they were formulated and the raw data was input into visual studio
to obtain optimal solution.
4.3 PROGRAM OUTPUT
4.3.1 Correct Data Input:
Correct data was input in the problems below
Problem 4.1 (Guy, Krik R, Nelson J.J Cole E. 2004)
Looking at the chemical process industries in the 1950’s, the information pertaining to the
expected yields of the fifteen types of crude oils when processed by the refinery is as shown
17
in page 67. Note that the product distribution from the refinery is quite different for the
fifteen crude oils. The limitations on the established markets for the various products in
terms of the allowed maximum daily production were given.
To set up the linear programming problem, formulate an objective function and constraints
for the refinery operation.
Solution
Let the variable be: X1 = bbl/day of crude #1
X2 = bbl/day of crude #2
X3 = bbl/day of crude #3
X4 = bbl/day of crude #4
X5 = bbl/day of crude #5
X6 = bbl/day of crude #6
X7 = bbl/day of crude #7
X8 = bbl/day of crude #8
X9 = bbl/day of crude #9
X10 = bbl/day of crude #10
X11 = bbl/day of crude #11
X12 = bbl/day of crude #12
X13 = bbl/day of crude #13
X14 = bbl/day of crude #14
X15 = bbl/day of crude #15
X16 = bbl/day of propane
18
X17 = bbl/day of butane
X18 = bbl/day of LPG
X19 = bbl/day of Petroleum ether
X20 = bbl/day of ligroin
X21 = bbl/day of straight-run gasoline
X22 = bbl/day of kerosene
X23 = bbl/day of heating oil
X24 = bbl/day of gas oil
X25 = bbl/day of diesel fuel
X26 = bbl/day of lubricating oil
X27 = bbl/day of waxes
X28 = bbl/day of residual oil
X29 = bbl/day of asphalt
X30 = bbl/day of tar
The linear objective function Z (to be maximized).
Other constraints that exist or are implied in this problem are given below. These can be
formulated as inequality constraints:
Propane: X16 48
Butane: X17 51
LPG: X18 46
Petroleum ether: X19 41
Ligroin: X20 47
19
Straight-run gasoline: X21 44
Kerosene: X22 43
Heating oil: X23 43
Gas oil: X24 41
Diesel fuel: X25 49
Lubricating oil: X26 64
Waxes: X27 54
Residual oil: X28 56
Asphalt: X29 59
Tar: X30 45
Maximize Z =
151413121110987654321 54243242
Subject to
20
4523222233
5925242224
56232322344
5422332223233
6425233232223
4932223232
412222222
43222222223
432223322
4422222423
474222222
4122223222
4632215223
513222223223
48222322222
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
151413121110987654321
X
X
21
Figure 4.1 Formulation of Revised Simplex Method.
Figure 4.2 Optimal Solution Revised Simplex Method Using Visual Studio 2005
22
4.3.2 Excel Solver Solution:
Microsoft Excel Provides tool called Solver that handles this problem in a manner that is
transparent to the user. The dynamic display of the iterative search process enables the user
to monitor location of the optimum solution by the search algorithm
Figure 4.3 Showing Solver Parameters
23
Figure 4.4 Solver Options
Figure 4.5 9(a) Solver Results
24
Figure. 4.6 Solver Results Solution
25
Table 4.1 COMPARISONS BETWEEN REVISED SIMPLEX METHOD AND
EXCEL SOLVER
No of
Variables
Revised Simplex
Method
Excel Solver
Solution
Observation
X2 0.59091 0.5909091 X2 in Rsimplex method
solution is the same in Excel
solver Solution
X4 6.27273 6.2727273 X4 in Rsimplex method
solution is the same in Excel
solver Solution
X7 4.64773 4.647727 X7 in Rsimplex method
solution is the same in Excel
solver Solution
X12 3.12500 3.125000 X12 in Rsimplex method
solution is the same in Excel
solver Solution
X14 6.52273 6.522727 X2 in Rsimplex method
solution is the same in Excel
solver Solution
z 85.32955 85.32955 Optimal Solution is the same
in Rsimplex and Excel Solver
Solution.
26
4.3.3 Analysis of Problem 4.1
The objective function and constraints for the refinery operation was formulated using
visual studio 2005 and the optimal solution was determined in Problem 4.1 This problem
was compared with Excel Solver Solution. The Optimal Solution for both applications is
the same.
Problem 4.2: Production Planning (Vasant P.M, 2003)
Eleven products are processed through different operations. The times (in minutes)
required per unit of each product, the daily capacity of the operations (in minutes per day)
and the profit per unit sold of each product (in dollars) are as shown below.
The zero times indicate that the product does not require the given operation. It is assumed
that all units produced are sold. Moreover, the given profits per unit are net values that
result after all pertinent expenses are deducted. The goal of the model is to determine the
optimum daily production for the eleven products that maximizes profit.
27
Max Z= 1110987654321 2323432
Subject to
512353
643424222
85234244336
7943346523
7532642323
442342
644422332
77434424233
593233244
582324232
47222332
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
X
X
28
Figure 4.7 Formulation of Revised Simplex Method.
Figure 4.8 Optimal Solution in Revised Simplex Method Using Visual Studio 2005
29
Problem 4.3 (Textile Technology Spinning, 2008).
The Concrete Products Corporation has the capability of producing eleven types of
concrete blocks. The plant manager desires to maximize the profit during the next month.
Max Z= 1110987654321 532423
Subject to
512353
643424222
85234244336
7943346523
7532642323
442342
644422332
77434424233
593233244
582324232
47222332
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
1110987654321
X
X
30
Figure 4.9 Formulation of Revised Simplex Method.
Figure 4.10 Optimal Solution Revised Simplex Method Using Visual Studio 2005
31
Problem 4.4 (James H. Gary and Glenn E. handwork, 2001)
Reid Vapor Pressure
The desired RVP of a gasoline is obtained by blending n-butane with C5-38oF (C5-193oC)
naphtha. The amount on n-butane required to give the needed RVP is calculated by: