Linear Programming with MATLAB PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document provides a chapter on linear programming, focusing on concepts, definitions, and methods using MATLAB. It features examples and problems, illustrating optimization techniques within those models.
Full Transcript
Chapter 2 Linear Programming with MATLAB Chapter 2 Linear programming (L.P) 2.1. Mathematical definition of L.P Linear programs are constrained optimization models that satisfy three requirements. 1. The decision variables must be continuous; they can take on any value withi...
Chapter 2 Linear Programming with MATLAB Chapter 2 Linear programming (L.P) 2.1. Mathematical definition of L.P Linear programs are constrained optimization models that satisfy three requirements. 1. The decision variables must be continuous; they can take on any value within some restricted range. 2. The objective function must be a linear function. 3. The left-hand sides of the constraints must be linear functions. Thus, linear programs are written in the following form: where the xj values are decision variables and cj, aij , and bi values are constants, called parameters or coefficients, that are given or specified by the problem assumptions. Most linear programs require that all decision variables be nonnegative. 1 Chapter 2 Linear Programming with MATLAB Therefore, we can transform the above linear program into matrix system form as following Min (or Max) ๐ ๐ โ ๐ subject to ๐ด๐ โค ๐ { ๐ด๐๐ ๐ = ๐๐๐ ๐๐ โค ๐ โค ๐ข๐ Where ๐ฅ1 ๐ ๐ = (๐1 , ๐2 , โฆ ๐๐ ), ๐ = ( ๐ฅ2 ), A is inequality constraint matrix, B is inequality vector, Aeq is โฎ ๐ฅ๐ equality constraints matrix, Beq is equality vector, lb is lower bounds of X and ub is the upper bounds. Illustration examples: Example1: Optimal cutting The well-posed problem: Letโs assume that GTP (major oil works) company has in stock 2000 piping pieces ( raw materials, feedstock) with their dimensions are all of 5 meters length and 12 inch of diameter ( 2000*5*12โโ). All of these pieces have to be cut into two types of pieces denoted by A=2 m and B=1.5 m, in order to manufacture valves (v) that requires 1V=3*A+2*B. Question: Establish a mathematical model (more precisely, statistical model) that expresses the posed problem in order to maximize valves production! Solution: ๏ Step1: Establishing a synoptic diagram of our posed problem (production chain) 2000 Supply, *(5*12โโ) (Procurement) Piping transport and pieces logistics Storage Cutting workshop Production factory (All cutting cases) 2 Chapter 2 Linear Programming with MATLAB ๏ Step2: Establishing an organization table (a matrix model) Letโs designate the number of times of first type cutting, second type cutting and third type by variables X1, X2, and X3 respectively, and we denote by X4 the production sum (total production). Therefore, we have the following table: Notation A=2m B=1.5m C={0,1,0.5} X1 2 0 1m X2 0 3 0.5m X3 1 2 0m X4 3 2 / The variable c={0, 1, 0.5} called cutting scraps From the above table, it seems clear that X1 is the optimal solution, which yields indeed a contradiction. Therefore, we need a combinatorial solution between (X1, X2 and X3). The question that arises is as How many times one use of X1, X2 and X3 ?. Step 3: Establishing the mathematical linear programming Constraints 1- Constraints between cutting workshop and production By applying the principle of equilibrium that means: ''supply must be greater than or equal to demand'' then we have 2๐ฅ + 1๐ฅ2 + 0๐ฅ1 โฅ 3๐ฅ4 { 1 โ โ โ ๐ด cut in the โ ๐ด Required for the workshop production 0๐ฅ + 3๐ฅ2 + 2๐ฅ1 โฅ 2๐ฅ4 { 1 โ โ โ ๐ต cut in the โ ๐ต Required for the workshop production 3 Chapter 2 Linear Programming with MATLAB 2- Exhaustion stock constraint (all pieces must be cut) ๐ฅ1 + ๐ฅ2 + ๐ฅ3 = 2000 Objective function The objective is to minimize the piping scraps that means equivalent to maximize the production Max (the production)โน ๐๐๐ฅ(๐ฅ4 ) Finally, the linear programming is given as following ๐๐๐ฅ(๐ฅ4 ) Subject to 2๐ฅ1 + 1๐ฅ2 + 0๐ฅ1 โฅ 3๐ฅ4 0๐ฅ1 + 3๐ฅ2 + 2๐ฅ1 โฅ 2๐ฅ4 { ๐ฅ1 + ๐ฅ2 + ๐ฅ3 = 2000 ๐ฅ1 , ๐ฅ2 , ๐ฅ3 โฅ 0 2.2. Programming method by using MATLAB 2.2.1. Simple case (without optimization) Example: ๐๐ + ๐๐ + ๐๐ = ๐ { ๐๐ + ๐ โ ๐๐ = ๐ ๐ + ๐๐ + ๐ = ๐ The above system admits a unique solution because its matrix is invertible. The program Method 1: using direct method ( command window) Method 1.1: using invertible matrix method 1.2: using diagonalization 4 Chapter 2 Linear Programming with MATLAB Method 2. Using algorithm Gauss ( scrip program) 5 Chapter 2 Linear Programming with MATLAB 2.2.2. Linear Programming with Optimization ๏ The general form ( for MATLAB) maxโก(โก๐๐ min)โกโ f T โ X Subject to constraints ๐ด๐ โค ๐ โฆ โฆ ๐๐๐๐ ๐ก๐๐๐๐๐๐โก๐๐๐๐๐ข๐๐๐๐ก๐ฆ { ๐ด๐๐ = ๐๐๐ โฆ โฆ. ๐๐๐๐ ๐ก๐๐๐๐๐๐โก๐๐๐ข๐๐๐๐ก๐ฆ ๐๐ โค ๐ โค ๐ข๐ โฆ โฆ ๐๐๐ข๐๐โก๐๐๐๐ ๐ก๐๐๐๐๐ก๐ โก๐๐โก๐กโ๐โก๐๐๐๐๐ ๐๐๐โก๐ฃ๐๐๐๐๐๐๐๐ Numerical example 1 ๏ง Posed problem: A production company produces two types of products (P1 and P2) using three different types of raw materials (m1, m2 and m3), with the following distribution: P1 P2 Availability in stock M1 2 1 800 M2 1 2 700 M3 0 1 300 6 Chapter 2 Linear Programming with MATLAB Question: Establish an optimal production plan knowing that the unit prices of production are respectively: 4 thousand DA and 5 thousand DA. ๏ง Modelization Here, we seek to maximize the total cost (maximize the profit) We denote P1 by x1 and P2 by x2 maxโก(4๐ฅ1 + 5๐ฅ2 ) ๐ ๐ข๐๐๐๐๐กโก๐ก๐ 2๐ฅ1 + ๐ฅ2 โค 800 ๐ฅ1 + ๐ฅ2 โค 700 ๐ฅ2 โค 300 { ๐ฅ1 , ๐ฅ2 , ๐ฅ3 โฅ 0 ๏ MATLAB programming( in command window: with linprog function) Remark: the linprog command is programmed only by a min objective. For this purpose, to maximize it is enough to change the sign. Numerical example 2: ๏ง Posed problem: A valve manufacturing company has in stock a quantity of 500 pieces of piping measuring (5mx12''). These must be cut into two types of pieces denoted by A=2m and B=1.5m, to manufacture valves which require 3 units of A and 2 units of B. Question: establish an optimal cutting plan. ๏ง Modelization - Here, we seek to minimize the falls (the faults) which is equivalent with to maximizing the production. - We denote by x1, X2 and X3 the numbers of cutting according to cases Nยฐ1, Nยฐ2 and Nยฐ3 respectively. - Finally, we obtain the following plan: 7 Chapter 2 Linear Programming with MATLAB Cutting case denoted A=2m B=1.5m C={0, 0.5, 1}m Nยฐ1 X1 2 0 1 Nยฐ2 X2 0 3 0.5 Nยฐ3 X3 1 2 0 Production X4 3 2 From the above table, we can establish the following mathematical model: maxโก(๐ฅ4 ) maxโก(๐ฅ4 ) ๐ ๐ข๐๐๐๐๐กโก๐ก๐ ๐ ๐ข๐๐๐๐๐กโก๐ก๐ 2๐ฅ1 + 0. ๐ฅ2 + 1. ๐ฅ3 โฅ 3๐ฅ4 โ2๐ฅ1 โ 0. ๐ฅ2 โ 1. ๐ฅ3 + 3๐ฅ4 โค 0 โบ 0๐ฅ1 + 3. ๐ฅ2 + 2. ๐ฅ3 โฅ 2๐ฅ4 โ0๐ฅ1 โ 3. ๐ฅ2 โ 2. ๐ฅ3 + 2๐ฅ4 โค 0 ๐ฅ1 + ๐ฅ2 + ๐ฅ3 = 500 +๐ฅ1 + ๐ฅ2 + ๐ฅ3 = 500 { ๐โฅ0 ๐โฅ0 ๏ง MATLAB programming Remark: here, we have used the integer function (intlinprog), because the variables are integers. Finally, we will produce 166 products with this optimal solution. 8 Chapter 2 Linear Programming with MATLAB 2.3. Hydrocarbon transport programming ๏ What is transportation problem? It is a linear program, which can be described as follows: We assume on the one hand a set of producers (or warehouse or something like suppliers (providers) and on the other hand a set of consumers (or customers), as indicated in the figure below ๐ฅ11 The objective is to minimize the total transport cost while respecting demand constraints and production capacities. Then the model can be defined as follows: ๐ ๐ min โ โ ๐ถ๐๐ ๐ฅ๐๐ ๐ฅ๐๐ ๐=1 ๐=1 Subject to ๐ โ ๐ฅ๐๐ โค ๐๐โกโก โก๐๐๐โก๐๐๐โโก๐ = 1, โฆ ๐,โกโกโกโกconstraintsโกonโกproductionโกcapacityโก ๐=1 ๐ โ ๐ฅ๐๐ โฅ ๐๐โกโก โก๐๐๐โก๐๐๐โโก๐ = 1, โฆ ๐,โกโกโก๐๐๐๐ ๐ก๐๐๐๐๐ก๐ โก๐๐โก๐ ๐๐ก๐๐ ๐๐ฆ๐๐๐โก๐๐๐๐๐๐โก ๐=1 ๐ฅ๐๐ โฅ 0 Numerical application for Hydrocarbon transport: We apply the transport model in hydrocarbon transport (in the collection network). We set the number of producers N=2 (here it concerns the wells) and the number of suppliers M=3 (here it concerns the treatment center). min ๐ ๐ ๐ โบ min(1โก2โก3โก2โก4โก1) โ ๐ ๐ ๐ Subject to 9 Chapter 2 Linear Programming with MATLAB ๐ฅ11 1 1 1 0 0 0 900 ๐ฅ12 0 0 0 1 1 1 800 ๐ฅ13 โ1 0 0 โ1 0 0โก โค โ500 0 โ1 0 ๐ฅ21 0 โ1 0 โ600 (0 0 โ1 0 0 โ1 ) (๐ฅ22) (โ300) ๐ฅ23 ๏ Matlab programming ( first method) 10