Linear Programming with MATLAB PDF

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

Use Quizgecko on...
Browser
Browser