La presentazione è in caricamento. Aspetta per favore

La presentazione è in caricamento. Aspetta per favore

Corso RICERCA OPERATIVA USO DI EXCEL PER ANALISI DI SCENARI E OTTIMIZZAZIONE Corso di Laurea in Ingegneria dei Trasporti Corso di Laurea Magistrale in.

Presentazioni simili


Presentazione sul tema: "Corso RICERCA OPERATIVA USO DI EXCEL PER ANALISI DI SCENARI E OTTIMIZZAZIONE Corso di Laurea in Ingegneria dei Trasporti Corso di Laurea Magistrale in."— Transcript della presentazione:

1 Corso RICERCA OPERATIVA USO DI EXCEL PER ANALISI DI SCENARI E OTTIMIZZAZIONE Corso di Laurea in Ingegneria dei Trasporti Corso di Laurea Magistrale in Ingegneria Meccanica Corso di Laurea Magistrale in Ingegneria dei Sistemi di Trasporto Laura Palagi Dipartimento di Informatica e Sistemistica A. Ruberti Sapienza Universita` di Roma

2 Capital Budgeting (Pianificazione degli Investimenti) Unazienda deve considerare tre possibili progetti sui cui investire nel corso dellanno Definizione del problema Data Budget15 milioni Ogni progetto richiede un investimento (I) Ogni progetto produce un Guadagno (G) Consideriamo il problema di Capital Budgeting

3 Capital budgeting: un possibile scenario Per ogni progetto Selezionato (YES = 1) Non selezionato (NO = 0) Investimento richiesto = = 13 Guadagno ottenuto = = 19 E` la migliore possibile ?

4 Capital budgeting: costruzione del modello Soluzioni ammissibili Definiscono le possibili alternative Per ogni progetto Selected (YES = 1) Not selected (NO = 0)

5 Capital budgeting Budget15 milioni Tutte le possibilita` Non accettabile Sono tutte compatibili con il budget ?

6 Un possibile modello di capital budgeting Le scelte ammissibili F= Miglior valore Qual e` la migliore rispetto ai guadagni ?

7 Perche e` un modello sbagliato Feasible solutionsRappresentazione esaustiva 2 n = numero enorme per valori grandi di n Non indipendente dai dati Se i dati cambiano, e` necessario riscrivere ex novo tutto il modello Potrebbe addirittura essere impossibile scriverlo

8 Un modello migliore Rappresentazione implicita delle soluzioni ammisibili Indipendente dai dati xi=xi= 1 se il progetto i e` selezionato 0 se il progetto i NON e` selezionato Variabili di decisione Vincolo di Budget8 x 1 +6 x 2 +5 x 3 Investment for project 1 Investment for project 2 budget Investment for project 3

9 Un modello migliore xi=xi= 1 if project i is selected 0 if project i is not selected guadagni12 x 1 +8 x 2 +7 x 3 earnings for project 1 Earnings for project 2 Earnings for project 3 Se cambiano i dati, solo I coefficneti dei vncoli e della funzione obiettivo devono essere modificati, ma non le funzioni matematiche, cioe` il modello che rimane lo stesso

10 Modello matematico di Capital budgeting Funzione obiettivo 12 x 1 +8 x 2 +7 x 3 max earnings Decision variables xi=xi= 1 if project i is selected 0 if project i is not selected i=1,2,3 vincoli 8 x 1 +6 x 2 +5 x 3 budget x 1, x 2, x 3 Programmazione lineare intera (PLI)

11 Il modello di Capital Budget in Excel data Possiamo rappresentare i dati del modello in una tabella Excel Se cambiano i dati, e` necessario modificare solo questa parte della tabella Excel

12 Variabili di decisione (intere) c7,d7,e7

13 Il modello di Capital Budget in Excel Variabili di decisione (intere) c7,d7,e7 Dobbiamo ora definire nuove celle nella tabella Excel che consentano di definire il modello matematico: 1. Variabili di decisione: dobbiamo assegnare dei valori inziali (stima iniziale) che consentano di valutare le funzioni

14 Il modello di Capital Budget in Excel Objective C5*C7+D5*D7+E5*E 7 Integer decision variables c7,d7,e7 Constraint C4*C7+D4*D7+E4*E7 data Dobbiamo ora definire delle celle nella tabella Excel che consentano di definire il modello matematico

15 r.h.s = budget Valore l.h.s. del vincolo C4*C7+D4*D7+E4*E7

16 Funzione obiettivo C5*C7+D5*D7+E5*E 7

17 Objective C5*C7+D5*D7+E5*E 7 Integer decision variables c7,d7,e7 data

18 Solving Capital Budget with Excel Objective function

19 Solving Capital Budget with Excel Variables (b6,c6,d6) are 0-1

20 Solving Capital Budget with Excel x 1 x 2 x 3 = 0 x 1 x 2 x 3 int

21 italian english Solving Capital Budget with Excel

22

23 Excel: an easy platform to optimization Excel has an optimization toolbox: Solver Solver Add-ins Tool s

24

25

26 Solving PL with Excel In the main menù select Tools (Strumenti) and then Solver (solutore)

27 Solving PL with Excel It will appear a dialog window like below Objective function Tipo di problema (max o min) Decision variablesConstraints Let now fill in

28 Setting the objective function Objective function P TOT = c9 The value can be set easily by clicking the corresponding cell (it puts the address $c$)

29 Setting the initial guess We need to give an initial value (also zero is feasible) = guess Cells C8 and D8 contains the value of the variables. At the end of the optimization process they contain the optimal value

30 Setting the constraints Clich Add (Aggiungi) Window of constraints

31 Setting the constraints ItalianEnglish Address of the cell or a constant Address of the cell Constraint can be of the type A B A Int (integer value) A bin (binary value 0,1)

32 Setting the options We must Assume Linear Model (use simplex method) and non- negative variables (in alternative we can define the additional constraints c8, d8 0). Clicking Options (Opzioni) the window of parameters appears

33 Setting the options Maximum time allowed to obtain a solution Maximum iterations of the algorithm to obtain a solution It uses an algorithm for linear problems (simplex) More complex models (non linear)

34 Solve LP con Excel We can start optimization Click the button Solve (Risolvi)

35 Final result with Excel Guess initial values have been substituted by the optimal ones The algorithmic solution is the same obtained with the graphical solution

36 Changing the options for LP Reducing timeReducing iterationsReducing or increasing tolerance Same solution

37 Changing the options for LP Same solution Change the model In general this is not true

38 Solving Capital Budget with Excel Objective function

39 Solving Capital Budget with Excel Variables (b6,c6,d6) are 0-1

40 Solving Capital Budget with Excel x 1 x 2 x 3 = 0 x 1 x 2 x 3 int

41 italian english Solving Capital Budget with Excel

42

43 Changing the options for ILP Reducing timeReducing iterations same solution but the Solver is not able to certify optimality

44 Changing the options for ILP Increasing Tolerance SOLUTION CHANGES Optimality declared, but it is not true

45 Production planning An engineering factory produces two types of tools: pliers and spanners. Pliers cost to the production 1.5 each Spanners cost to the production 1 each Pliers are sold at 6 each Spanners are sold at 5 each How much should the factory produce to maximize its profit ? Production costs Selling price Objective function

46 A possible scenario Assume that we are constructing P TOT = number of pliers * unit profit for pliers + number of spanners * unit profit for spanners pliers spanners Let us define the data of the problem 4,5 = (6 – 1,5) unit profit for pliers4 = (5 – 1) unit profit for spanners unit profit = selling price – unit cost Objective function = total profit P TOT

47 A possible scenario (2) CH = number of spanners to be produced PI = number of pliers to be produced P TOT = 4 CH + 4,5 PI = 4 * ,5 * = Equation of the overall profit Formally: variables output of our model Unit profit of spanners Unit profit of pliers Is this the best value ?

48 First use of Excel for data storing We use an Excel table to summarize data and objective P TOT = 4 CH + 4,5 PI Profit equation C9 = C6 * C8 + D6 * D8 Excel formulaCH = D8 = number of pliers PI = C8 = number of spanners 4,5= unit profit pliers = D4 – D5 4 = unit profit spanners = C4-C5

49 Constraints Every point in the non negative quadrant is a possible feasible solution (a possible production planning) Spanners (thousands) Pliers (thousands) In practice: constraints exist that limit the production In principle: the more I produce the more I gain ! (25000) overall profit (68000) (127500)

50 A standard constraint: the budget one Budget constraint: the overall cost must not greater than C TOT = overall cost CH = D8 = number of pliers PI = C8 = number of spanners C TOT = 1 CH +1,5 PI Unit cost spanner Unit cost pliers Cost equation C11 = C5 * C8 + D5 * D8 C TOT = 1 CH + 1,5 PI budget =18000 Budget constraint

51 Geometric view of the constraint Let draw the set F of the feasible solutions In the plane (PI, CH), first draw the equation of the Feasible region All non negative points below the line budget constraint 1 CH + 1,5 PI = 18 C TOT = C TOT = : ammissibile > 18000: non ammissibile C TOT = *CH + 1,5* PI = CH PI

52 Geometric view of the problem We need to find the right solution among the feasible ones right It satisfies the budget constraint It maximizes the profit Points in the red area satisfies the budget constraint, which is the better one ? CH 12 PI *CH + 1,5* PI = 18

53 Scenarios with Excel Let us see with different scenarios feasible Not feasible feasible Best among the three feasible. Is the optimum ? By chance ?

54 Limit of the What If approach The scenarios are too many: infinite solutions ! It is not possible to look over all of them !! We may wonder if may be better when the number of solutions is finite This is not always true, let see with an example

55 Construction of a good model: general rules xi=xi= 1 if project i is selected 0 if project i is not selected Definition of the objectives 12 x 1 +8 x 2 +7 x 3 Definition of the decision variables max earnings Definition of the constraints 8 x 1 +6 x 2 +5 x 3 budget i=1,2,3

56 Geometric view of the production problem The scenarios are too many 12 CH PI *CH + 1,5* PI = 18 P TOT = 69 Actual best value Draw the line of the profit P TOT 4 CH + 4,5 PI = 69 We must find another method Depict the feasible region F (red area)

57 Geometric view of the problem 12 CH PI *CH + 1,5* PI = 18 Growing direction P TOT = 72 Draw the line of the profit P TOT 4 CH + 4,5 PI For growing values of P TOT = P TOT = P TOT = 0 0 P TOT = Optimum !! Old best value

58 Another constraint: technology To produce 1000 pliers or 1000 spanners is required 1 hour of usage of a plant CH = D8= number of spanners PI = C8= number of pliers The plant can work for a maximum of 14 hours per day H TOT = total hours nedeed H TOT = CH PI Equation of the total hours C11 = C7 * C8 + D7 * D8 Technological constraint H TOT = CH PI max_hours=14

59 14 PI CH *CH + 1* PI = 14 hours 16 > 14: not feasible 16 Geometric view of the technological constraint CH PI 14 1 CH + 1 PI In the plane (PI, CH), first draw the equation of the technological constraint Feasible region of the technological constraint 14: feasible hours 6

60 Mixing the two constraints We must put together budget and technological constraints. Both must be satisfied Spanner Plier Both violated budget violated technological satisfied Budget satisfied technological violated Both satisfied

61 Geometric view of both constraints CH PI *CH + 1* PI = 14 1*CH + 1,5* PI = 18 Hours: feasible Budget: not feasible Hours: not feasible Budget: feasible Feasible set F Hours: not feasible Budget: not feasible Hours: feasible Budget: feasible Not feasible points

62 Final feasible region Feasible solutions (CH,PI) satisfy: CH 0 PI 0 Non negativity 1 CH + 1,5 PI 18 1 CH + 1 PI 14 budget hours Which is the best value for (CH,PI)* among the feasible ones ? The best one (CH,PI)* maximizes the profit 4 CH + 4,5 PI 1 CH + 1,5 PI = 18 CH PI CH + 1 PI = 14 F

63 Linear Programming 1 CH + 1,5 PI 18 1 CH + 1 PI 14 budget hours CH 0PI 0 Non negativity LINEAR PROGRAMMING (LP) Max or Min of one linear objective function Constraints are linear equalities (=) or inequalities ( = ) max 4 CH + 4,5 PI CH, PI R Objective function profit constraints CH,PI Real decision variables CH, PI R

64 Construction of a good model: general rules Definition of the objectives Definition of the decision variables 4 x 1 +4,5 x 2 max profit Definition of the constraints x 1 + 1,5 x 2 budget CH, PI R x 1, x 2 R x 1 + x 2 hours x 1, x 2 The name is not important

65 Graphical solution for LP PI CH 1 CH + 1,5 PI = CH + 1 PI = 14 Let choice a feasible point The profit P TOT is 4 CH + 4,5 PI = 34 (34000 ) Better solution must have a value of P TOT 34 The idea is looking for solutions that satisfy also the new fictitious constrait 4 CH + 4,5 PI 34. (4,4) (4000 spanners e 4000 pliers) P TOT = 34

66 Graphical solution for LP PI 1 CH + 1,5 PI = CH + 1 PI = 14 CH 4 CH + 4,5 PI = 34 Draw the new feasible region F Let choice (2,10). with Excel A better solution (if any) must be in the new feasible region F F The profit P TOT is now 4 CH + 4,5 PI = 53 (53000 ) P TOT = 53

67 Graphical solution for LP CH The feasible region F is more and more narrow (violet region) PI 1 CH + 1,5 PI = CH + 1 PI = 14 4 CH + 4,5 PI = 53 Increasing values of P TOT The region with the constraint P TOT > 60 is empty !!! Behind this point (6,8) with P TOT = 60, there are non more feasible better points P TOT = 60 The point (6,8) is the best feasible one

68 Graphical solution of LP: summary 1.Draw the constraints and the feasible region 2.Choice a feasible point 3.Draw the line of the objective function passing for this point 4.Parallel move the line of the objective function in the direction of better values 5.The last feasible point touched by the line is the optimal solution When the number of variables is two:

69 Solution of LP We use Excel Solver (www.frontsys.com) Graphical solution can be applied only when the number of variables is two Real problems has usually more than two variables Many standard software exist to solve LP problems of different level of complexity Computer must be used as a tool to tackle large quantities of data and arithmetic


Scaricare ppt "Corso RICERCA OPERATIVA USO DI EXCEL PER ANALISI DI SCENARI E OTTIMIZZAZIONE Corso di Laurea in Ingegneria dei Trasporti Corso di Laurea Magistrale in."

Presentazioni simili


Annunci Google