Optimization Broadly two types: Unconstrained and Constrained optimizations We deal with constrained optimization General form: Min or Max f(x) (1) Subject to g(x) ~ b (2) lo < x < up (3)
Some important terms Eq1 is called objective function and if it is of nonlinear function of x vector of variables then it is called non-linear mathematical programming problem Eq2 is called constraint function and it can either be linear or non-linear function of x Eq3 is the boundary conditions of the variable x Optimization problem can either be maximizing or minimizing the Eq1 satisfying the constraints eqs 2 and 3 simultaneously.
Terms ~ indicates the relation between g(.) and b and it can either be equal or unequal depending upon the problem in hand If both the objective and constraint functions are linear then the problem becomes linear optimization Optimization problems can be continuous, integer or mixed integer depending upon types of value variables x take
Linear programming (LP) LP is a tool for solving linear optimization problems. Simplex algorithm: A tool for solving LP problems (Dantzig 1947). LP has been used to solve optimization problems in various industries, e.g. forestry, banking, trucking etc.
An illustration of LP A company makes 2 types of wooden toys: dolls and trucks. A doll sells for $27, uses $10 of raw material and other costs of $14. A truck sells for $21, uses $9 of raw material and other costs of $10. A doll requires 2 hours of carpentry and 1 hour of painting work. A truck requires 1 hour of carpentry and 1 hour of painting work. Each week only 100 painting hours and 80 carpentry hours are available. Raw material supply is unlimited. Demand for trucks is unlimited, but at most 40 dolls can be sold per week. Formulate a LP problem to maximize the company s profit.
Decision Variables Decision variables : should completely define the decisions to be made. x 1 = no. of dolls produced per week x 2 = no. of trucks produced per week
Objective Function In any LP problem the decision maker wants to maximize (usually revenue or profit) or minimize (usually costs) some function of the decision variables. What is the objective in Example 1? Maximize profit = revenues costs Costs Fixed costs: does not depend on decision variables (e.g. rent) Variable costs: raw material costs + other variable costs. Revenues weekly revenues from dolls + weekly revenues from trucks.
Objective Function Revenues = weekly revenues from dolls + weekly revenues from trucks. Rev. = (selling price per doll * no. of dolls per week) + (selling price per truck * no. of trucks per week) Rev. = 27*x 1 + 21*x 2.
Objective Function Weekly raw material costs = 10 x 1 + 9 x 2 Other weekly variable costs = = 14 x 1 + 10 x 2 So, profits = (27 x 1 + 21 x 2 ) (10 x 1 +9 x 2 ) (14 x 1 + 10 x 2 ) = 3x 1 +2x 2 Therefore, objective function = Maximize z = 3*x 1 +2*x 2 The coefficient of a decision variable in the objective function is called an objective function coefficient. The variable z is used to represent the objective function value of any LP.
Constraints Constraints : restrictions that limit the values of the decision variables. Constraints for Example 1: c 1 ) No more than 100 hours of painting time can be used per week. c 2 ) No more than 80 hours of carpentry time can be used per week. c 3 ) Due to limited demand, at most 40 dolls should be produced per week.
Constraint c 1 c 1 ) No more than 100 hours of painting time can be used per week. Total painting hours per week = (painting hours per doll * no. of dolls per week) + (painting hours per truck * no. of trucks per week) = 2 * x 1 + 1 * x 2 = 2 x 1 + x 2 c 1 : 2 x 1 + x 2 < 100 (2) The coefficient of a decision variable in a constraint is often called a technological coefficient
Constraint c 2 c 2 ) No more than 80 hours of carpentry time can be used per week. Total carpentry hours per week = (carpentry hours per doll * no. of dolls per week) + (carpentry hours per truck * no. of trucks per week) = 1 * x 1 + 1 * x 2 = x 1 + x 2 c 2 : x 1 + x 2 < 80 (3)
Constraint c 3 c 3 ) Due to limited demand, at most 40 dolls should be produced per week. No. of dolls per week = x 1 Maximum no. of dolls produced per week = 40 c 3 : x 1 < 40 (4)
Sign Restrictions Can the decision variable assume only nonnegative values or both positive and negative values? If a decision variable (x i )can take only nonnegative values, we add sign restriction x i > 0. Otherwise we say x i is unrestricted in sign (urs).
LP Formulation for Example 1 Maximize z = 3*x 1 +2*x 2 (1) Objective function subject to (s.t.) 2*x 1 + x 2 < 100 (2) painting constraint x 1 + x 2 < 80 (3) carpentry constraint x 1 < 40 (4) demand constraint x 1 > 0 (5) sign restriction x 2 > 0 (6) sign restriction
Some Definitions Definition 1: A function f(x 1, x 2,, x n ) of x 1, x 2,, x n is a linear function if and only if for some set of constants c 1, c 2,, c n, f(x 1, x 2,, x n ) = c 1 x 1 +c 2 x 2 + +c n x n For example, f(x 1, x 2 ) = 2x 1 + x 2 is a linear function of x 1 and x 2, but f(x 1, x 2 ) = x 12 x 2 is not a linear function of x 1 and x 2 Definition 2: For any linear function f and any number b, the inequalities f(x 1, x 2,, x n ) b and f(x 1, x 2,, x n ) b are linear inequalities. Thus, 2x 1 + 3x 2 3 and 2x 1 + x 2 3 are linear inequalities, but x 12 x 2 3 is not a linear inequality.
Feasible Region The feasible region for an LP is the set of points satisfying all its constraints and sign restrictions. Is the point (x 1 = 40, x 2 = 20 ) in the feasible region for Example 1: Put these values (of x 1 and x 2 ) in each constraint (2)-(6) and check if the constraint is satisfied for each case. Ans: (x 1 = 40, x 2 = 20 ) is in the feasible region. Is the point (x 1 = 15, x 2 = 70 ) in the feasible region of Example 1: No, it violates (3) Is the point (x 1 = 40, x 2 = -20 ) in the feasible region of Example 1: No, it violates (6), i.e. sign restriction on x 2. Any point that is not in an LP s feasible region is called an infeasible point.
Optimal Solution For a maximization (minimization) problem, an optimal solution to an LP is a point in the feasible region with the largest (smallest) objective function value. Most LPs have one optimal solution. Some LPs have no optimal solution; some have an infinite number of solutions. What is the objective function value for (x 1 = 30, x 2 = 40 )? Is this optimal? What is the objective function value for (x 1 = 40, x 2 = 20 )? Is this optimal? What is the objective function value for (x 1 = 20, x 2 = 60 )? Is this optimal?
Feasible Solution for Example 1 constraints 2 6 only points in first quadrant satisfy sign restrictions. (2) is satisfied by all lines on or below line AB (3) is satisfied by all lines on or below CD (4) is satisfied by all points to the left of EF Feasible region is bounded by polygon DGFEH. 100 80 60 40 20 D x 2 B G F A C x 1 10 20 30 40 50 60 70 80 E
Optimal Solution for Example 1 (e1.gms) Optimal solution is the point in the feasible region with the largest value of z=3x 1 +2x 2 Draw a single isoprofit (isocost for min problem) line, z =60 Generate other isoprofit lines by moving parallel to the drawn isoprofit line, such as z=100 Point G is the last isoprofit line to intersect the feasible region. And the optimal value is 180 100 80 60 40 20 D x 2 B G E 10 20 30 40 50 60 70 80 F A Z = 60, 100, 180 C x 1
Some Assumptions Proportionality Assumption: The contribution of the objective function from each decision variable is proportional to the value of the decision variable. The contribution of each variable to the left-hand side of each constraint is proportional to the value of the variable. Additivity Assumption: The contribution to the objective function for any variable is independent of the values of the other decision variables. The contribution of a variable to the left-hand side of each constraint is independent of the values of the variable
Some Assumptions (cont d) Divisibility Assumption: each decision variable allowed to assume fractional values E.g., in Example 1, it implies that it is acceptable to produce 1.5 dolls, or 1.63 trucks. If divisibility is not valid, rounding off each variable in the optimal LP solution to an integer may yield a reasonable solution. Certainty Assumption: each parameter ( objective function coefficient, right-hand side, and technological coefficient ) is known with certainty. E.g if we were unsure of the exact amount of carpentry required to build a truck, the Certainty Assumption would be violated.
Infeasible LP It is possible for an LP s feasible region to be empty (contain no points). This results in an infeasible LP. An infeasible LP has no optimal solution e.g. in Example 1, suppose the company is required to make at least 90 trucks per week. x 2 > 90 (7) 100 I 80 60 40 20 D x 2 B G 10 20 30 40 50 60 70 80 E F A C J x 1
For a max (or min) problem, the LP is unbounded if it is possible to find points in the feasible region with arbitrarily large (or small) objective values. Unbouned LP 100 80 60 D x 2 B G Should not occur in a correctly formulated LP e.g. in Example 1, suppose there is no restriction on the amount of labour available. remove constraints (2) and (3) 40 20 F A C 10 20 30 40 50 60 70 80 E x 1
Exercise... (e2.gms) A company sells luxury goods and wants to reach Highincome Men (HM) and High-income Women (HW), by advertising on comedy shows and football games. A 1-minute spot on a comedy show is seen by 7M HW and 2M HM. A 1-minute spot on football game is seen by 2M HW and 12M HM. A 1-minute comedy ad costs $50,00 and a 1-minute football ad costs $100,000. The company wants to reach at least 28M HW and 24M HM. Formulate a LP problem to minimize the company s advertising costs.
Variables & Objective x 1 = no. of 1-minute comedy ads purchased x 2 = no. of 1-minute football ads purchased Total cost = cost of comedy ads + cost of football adds (cost per comedy ad * no. of comedy ads)+(cost per football ad * no. of football ads) 50,000 x 1 + 100,000 x 2 50 x 1 + 100 x 2 (in thousands of dollars) objective function: min z = 50 x 1 + 100 x 2 (1)
Constraints c 1 ) must reach at least 28 million HW no. of HW = (HW per comedy add * no. of comedy ads)+ (HW per football add * no. of football ads) = 7 x 1 + 2 x 2 > 28 (2) in millions of viewers c 2 ) must reach at least 24 million HM no. of HM = (HM per comedy add * no. of comedy ads)+ (HM per football add * no. of football ads) = 2 x 1 + 12 x 2 > 24 (3) in millions of viewers sign restrictions: x 1 > 0 ; x 2 > 0;
LP Formulation Min z = 50 x 1 + 100 x 2 s.t. 7x 1 + 2x 2 > 28 2 x 1 + 12 x 2 > 24 x 1, x 2 > 0
Graphical Solution x 2 c 1 satisfied by point on or above line AB 7x 1 + 2x 2 = 28 c 2 satisfied by point on or above line CD 2x 1 + 12 x 2 = 24 unbounded feasible region isocost line through (x 1 = 4, x 2 = 4); z = 600 E is last point in feasible region to intersect isocost line E = (x 1 = 3.6, x 2 = 1.4); optimal z = 320 14 12 10 8 6 4 2 B D E (4,4) C x 1 A 2 4 6 8 10 12 14 16 Z=320, Z=600
GAMS: Introduction GAMS (General Algebraic Modeling System) Programming language to formulate optimization problems Integrated interface to solver (for example Cplex) i. several solvers can be chosen ii. solver solves optimization problem (for example via Simplex algorithm) Website: http://www.gams.com useful information and additional tools
Language elements Case insensitive and user friendly language based on relational database theory Parameters i. exogenous data, fixed values ii. declaration of parameters and definition of values Variables i. declaration of variables that will be calculated by the model = decision variables ii. no defining of values Equations i. declaration and definition of equations describing the objective function and the restrictions Model and Solve i. name model (tell which equations are included, normally all) ii. specifying solving mode (linear, mixed-integer, ) and specifying whether objective function is to be minimized or maximized
GAMS IDE Create Project Open GAMS (gamside.exe) Create project i. create project file (File -> Project -> New Project) as C:\..\test.gpr ii. create new gms file (File -> New) as C:\..\e1.gms Test project i. type code of e1.gms file ii. run code (F9) iii. check listing file (e1.lst) Declaration: stating that something exists Definition: assignment of value/explicit equation