Optimization and Linear Programing-LingoFundamentals
Optimization and Linear Programing-LingoFundamentals
Programing:
Fundamentals of LINGO
Jorge Lliguizaca D.
Master Candidate
Major: Management Science and Engineering
Academy of Chinese Energy Strategy
China University of Petroleum - Beijing
1
Content
• An introduction to Modeling
• Linear Programming
• Lingo
• An illustrative numerical example
• How to prepare the model
• Solving the model
• Output interpretation
• Recommended Literature
2
An Introduction to Modeling
• Operations research (often referred to as management science) is simply a scientific approach to
decision making that seeks to best design and operate a system, usually under conditions requiring
the allocation of scarce resources.
• By a system, we mean an organization of interdependent components that work together to
accomplish the goal of the system. For example, Ford Motor Company is a system whose goal consists
of maximizing the profit that can be earned by producing quality vehicles.
• The scientific approach to decision making usually involves the use of one or more mathematical
models. A mathematical model is a mathematical representation of an actual situation that may be
used to make better decisions or simply to understand the actual situation better.
3
An Introduction to Modeling
–1.The problem is complex, and the manager cannot develop a good solution without the aid of
quantitative analysis.
–2. The problem is especially important (e.g., a great deal of money is involved), and the
manager desires a thorough analysis before attempting to make a decision.
–3. The problem is new, and the manager has no previous experience from which to draw.
–4. The problem is repetitive, and the manager saves time and effort by relying on quantitative
procedures to make routine decision recommendations.
5
An Introduction to Modeling
6
An Introduction to Modeling
Advantages of Models:
Generally, experimenting with models (compared to experimenting with the real situation):
• requires less time
• is less expensive
• involves less risk
7
An Introduction to Modeling
Computer Software
A variety of software packages are available for solving mathematical models.
• Microsoft Excel
• GAMS
• LINGO
• AMPL
• MATLAB
8
Linear programming
Why is Linear Programming is important?
1. Solve the business problems: With linear programming we can easily solve business problem. It
is very benefited for increase the profit or decrease the cost of business.
2. Easy work of manager under limitations and condition : Linear programming solve problem
under different limitations and conditions , so It is easy for manager to work under limitations and
conditions . It helps manager to decide in different limitations.
3. Use in solving staffing problems:
With linear programming , we can calculate the number of staff needed in hospitals ,mines , hotels
and other type of business.
4. Helpful in profit planning: Today linear programming is using for good profit planning
5. Select best advertising media: With linear programming we can select best advertising media
among a numbers of media.
6. Solve the diet problems: With linear programming you can solve the diet problems with
minimum cost. It is very useful for hospitals .There are different elements like vitamins, proteins,
9
carbohydrates etc. You can select best quantity of them with minimum cost.
Linear Programming
Linear programming (LP) is a technique for the optimization of a linear objective function, subject
to linear equality and linear inequality constraints.
• The maximization or minimization of some quantity is the objective in all linear programming
problems.
• All LP problems have constraints that limit the degree to which the objective can be pursued.
• A feasible solution satisfies all the problem's constraints.
• An optimal solution is a feasible solution that results in the largest possible objective function value
when maximizing (or smallest when minimizing).
• A graphical solution method can be used to solve a linear program with two variables.
10
Linear Programming
In all linear programming problems, the maximization or minimization of some quantity is the objective
11
Linear Programming
• The manufacturer is restricted by constraints requiring product demand to be satisfied and limiting
production capacity.
• The financial analyst’s portfolio problem is constrained by the total amount of investment funds
available and the maximum amounts that can be invested in each stock or bond.
• The marketing manager’s media selection decision is constrained by a fixed advertising budget
and the availability of the various media.
• The minimum-cost shipping schedule is constrained by the supply of product available at each
warehouse.
12
LINGO
• The process of solving a math program requires a large number of calculations and is,
therefore, best performed by a computer program.
• The main purpose of LINGO is to allow a user to quickly input a model formulation, solve it,
assess the correctness or appropriateness of the formulation based on the solution, quickly
make minor modifications to the formulation, and repeat the process.
13
LINGO
14
LINGO
• LINGO provides a completely integrated package that includes a powerful language for
expressing optimization models, a full-featured environment for building and editing
problems, and a set of fast built-in solvers capable of efficiently solving most classes of
optimization models.
• LINGO features a wide range of commands, any of which may be invoked at any time.
15
An illustrative numerical example
The carpenter's problem deals with finding out how many Tables XT and how many Chairs XC
tables XT to make per week. His net profits for one XT and one XC are $5 and $3, respectively.
That is, the net income (say, in dollars) from selling XT units of tables and XC units of chairs.
16
An illustrative numerical example
This is subject to constraining factors that usually come from outside, are the limitations on
labors (this limitation comes from his family) and raw material resources (this limitation comes
from scheduled delivery).
• Production times required for a table and a chair are measured at different times of day, and
estimated to be 2 hours and 1 hour, respectively.
• Raw materials required for a table and a chair are 1, and 2 units respectively.
17
An illustrative numerical example
• Maximize 5 XT + 3 XC
Subject to:
• 2 XT + XC ≤ 40 labor constraint
• XT + 2 XC ≤ 50 material constraint
• and both XT, XC are non-negative, i.e. XT ≥ 0, XC ≥ 0.
18
An illustrative numerical example
In general, an optimization model will consist of the following three (i.e. rows) items:
• Row 1: Objective Function: The objective function is a formula that expresses exactly what it
is you want to optimize.
• Other Rows are the Constraints: Almost without exception, there will be some limit on the
values the variables in a model can assume--at least one resource will be limited (e.g., time,
raw materials, your department's budget, etc.).
• Variables (or decision variables): These are the quantities you have under your control. You
must decide what the best values of the variables are. The goal of optimization is to find the
values of a model's variables that generate the best value for the objective function, subject to
any limiting conditions placed on the variables.
19
An illustrative numerical example
20
How to prepare the model to be solved by LINGO
21
How to prepare the model to be solved by LINGO
22
How to prepare the model to be solved by LINGO
• We have also entered some comments to improve the readability of our model. Comments
begin with an exclamation point (!) and end with a semicolon (;). All text between an
exclamation point and terminating semicolon is ignored by LINGO. Comments can occupy
more than one line and can share lines with other LINGO expressions. For example:
X = 1.5 * Y + Z / 2 * Y; !This is a comment;
X = 1.5 * !This is a comment in the middle of a constraint; Y + Z / 2 * Y;
23
How to prepare the model to be solved by LINGO
24
Solving the model
Your model has now been entered and it is ready to be solved. To begin solving the model, select
the Solve command from the LINGO menu, or press the Solve button on the toolbar at the top of
the main frame window. Or we can use the shortcut ctrl+u
LINGO will begin compiling the model. During this step, LINGO will determine whether the
model conforms to all syntax requirements
25
Solving the model
If the LINGO model doesn’t pass these tests, you will be informed by an error message. In this
model, for instance, if you forget to use the multiplication sign, you will get an error like the
following:
26
Output Interpretation
The solver status window is When LINGO is done solving the LINGO1 model, there will be a
useful for monitoring the new Solution Report window created on your screen containing
progress of the solver and the the details of the solution to your model. The solution report
should appear as in the figure
dimensions of your model. 27
Output Interpretation
• Objective function value: The value that we will get by the optimal
solution.
• Values of the decision variables: The values of the Optimal Solution
28
Output Interpretation
Reduced cost:
• The reduced cost for a
decision variable whose
value is 0 in the optimal
solution is the amount the
variable's objective function
coefficient would have to
improve (increase for
maximization problems,
decrease for minimization
problems) before this
variable could assume a
positive value.
• The reduced cost for a
decision variable with a
positive value is 0.
29
Output Interpretation
Slack/surplus
The information shown in
the Slack/Surplus column
provides the value of the
slack variable for each of
the departments.
30
Recommended Literature
• An Introduction to Management Science(13th ed): Quantitative Approaches to Decision
Making, 2011, David R. Anderson
• The Institute for Operations Research and the Management Sciences (INFORMS)
31
Thank you for your attention, the
feedback, the questions and comments
that improve the lecture level.
32