Sie sind auf Seite 1von 32

Optimization and Linear

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

• Steps for Problem Solving and


Decision Making

• The relationship between


problem solving and decision
making

• The seven Step Model Building


Process.

Source: An Introduction to Management Science(13th ed): Quantitative Approaches 4


to Decision Making, 2011, David R. Anderson
An Introduction to Modeling

Potential Reasons for a Quantitative Analysis Approach to Decision Making:

–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

Quantitative Methods in practice:


• Linear Programming
• Integer Linear Programming
• PERT/CPM
• Inventory models
• Waiting Line Models
• Simulation
• Decision Analysis
• Goal Programming
• Analytic Hierarchy Process
• Forecasting
• Markov-Process Models

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

MODELS SOLVE PROBLEMS

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

• The manufacturer wanted to minimize costs;

• The financial analyst wanted to maximize return on investment;

• The marketing manager wanted to maximize advertising effectiveness;

• The company wanted to minimize total transportation costs.

11
Linear Programming

Constraints are another general feature of every linear programming problem.

• 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 computer program we will use is called LINGO.

• 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

• LINGO is a comprehensive tool designed to make building and


solving mathematical optimization models easier and more
efficient.

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.

• LINGO checks whether a particular command makes sense in a particular context.

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.

Therefore his objective is to

Maximize his net total profit:

• Maximize 5XT + 3XC

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.

• Total labor hours per week are only 40 hrs.

• Raw materials required for a table and a chair are 1, and 2 units respectively.

• Total supply of raw material is 50 units per week.

17
An illustrative numerical example

Therefore, the LP formulation model is:

• 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

• This is a linear (because all variable have power of 1) programming


(not a Computer programming language), but its best (optimal)
solution (the pair of unknown XT, XC) programs the carpenter activity
for a week. We refer to this model the Carpenter Decision Problem.
• Now we will use LINGO to find the optimal solution for the Decision
Variable (XT, XC).

20
How to prepare the model to be solved by LINGO

• Note: Each mathematical expression in LINGO is


terminated with a semicolon. These semicolons are
required. Your model will not solve without them.

• Note: Since most computers do not have less-than-or-


equal-to keys (≤), LINGO has adopted the convention of
using the two character symbol <= to denote ≤. As an
alternative, you may simply enter < to signify less-than-
or-equal-to. In a similar manner, >= or > are used to
signify greater-than-or-equal-to (≥).

21
How to prepare the model to be solved by LINGO

• LINGO interprets the "<" symbol as less-than-or-equal-to rather than strictly-less-than.


• Similarly the ">" symbol as greater than-or-equal-to rather than strictly-less-than.
• The objective function should not contain any constant. For example, Max 5XT + 3XC + 100 is
not allowed. You add 100 to the profit later when you get LINGO solution.
• All variables must appear on the left-hand side of the constraints, while numerical values
must appear on the right-hand side of the constraints.
• All variables are assumed to be nonnegative. Therefore, do not enter the non-negativity
constraints.

22
How to prepare the model to be solved by LINGO

General LINGO Syntax


• An expression may be broken up into as many lines as you want, but the expression must be
terminated with a semicolon. As an example, we could have used two lines rather than just
one to contain the objective function:
Max= 5*XT
+ 3*XC;

• 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

General LINGO Syntax


• You may have noticed we used all uppercase letters for our variable names. This is not a
requirement. LINGO does not distinguish between uppercase and lowercase in variable
names. Thus, the following variable names would all be considered equivalent:
XT Xt xt
• When constructing variable names in LINGO, all names must begin with an alphabetic
character (A-Z). Subsequent characters may be either alphabetic, numeric (0-9), or the
underscore (_). Names may be up to 32 characters in length.
• A final feature you will notice is that LINGO’s editor is “syntax aware.” In other words, when it
encounters LINGO keywords it displays them in blue, comments are displayed in green, and
all remaining text is displayed in black. Matching parentheses are also highlighted in red
when you place the cursor immediately following a parenthesis. You should find this feature
useful in tracking down syntax errors in your models.

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:

Note: LINGO lets you know there is a


syntax error in your model, lists the line
of the model it is in, and points to the
place in the line where it occurred.

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.

Dual Price(Dual Value)


The change in the value of
the objective function per
unit increase in the right- Note: Using the dual price and the allowed ranges for the right hand side
hand side of a constraint. we can see which constraint has more influence in the objective function.

30
Recommended Literature
• An Introduction to Management Science(13th ed): Quantitative Approaches to Decision
Making, 2011, David R. Anderson

• Wayne. L. Winston,Operations Research: Applications and Algorithms

• Introduction to Operations Research (9th ed), 2010 Frederick S. Hillier

• Operations Research: An Introduction (9th Edition), 2010 , Hamdy A. Taha

• 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.

Thanks to ISAIP CUPB

32

Das könnte Ihnen auch gefallen