La presentazione è in caricamento. Aspetta per favore

La presentazione è in caricamento. Aspetta per favore

PER ANALISI DI SCENARI E OTTIMIZZAZIONE

Presentazioni simili


Presentazione sul tema: "PER ANALISI DI SCENARI E OTTIMIZZAZIONE"— Transcript della presentazione:

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

2 Capital Budgeting (Pianificazione degli Investimenti)
Consideriamo il problema di Capital Budgeting Definizione del problema Un’azienda deve considerare tre possibili progetti sui cui investire nel corso dell’anno Data Ogni progetto produce un Guadagno (G) Ogni progetto richiede un investimento (I) Budget 15 milioni

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

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

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

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

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

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

9 Un modello “migliore” xi= 1 if project i is selected
0 if project i is not selected guadagni 12 x1+8 x2+7 x3 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
Decision variables xi= 1 if project i is selected 0 if project i is not selected i=1,2,3 Funzione obiettivo 12 x1+8 x2+7 x3 max earnings vincoli 8 x1+6 x2+5 x3 budget x1, x2 , x3 Programmazione lineare intera (PLI)

11 Il modello di Capital Budget in Excel
Possiamo rappresentare i dati del modello in una tabella Excel data 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
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 Variabili di decisione (intere) c7,d7,e7

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

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

16 Funzione obiettivo C5*C7+D5*D7+E5*E7

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

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
x1 x2 x3<= 1 x1 x2 x3>= 0 x1 x2 x3 int

21 Solving Capital Budget with Excel
italian english

22 Solving Capital Budget with Excel

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

24

25

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

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

28 Setting the objective function
Objective function PTOT = 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
Italian English Constraint can be of the type A    B A Int (integer value) A bin (binary value 0,1) Address of the cell Address of the cell or a constant

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

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 time Reducing iterations Reducing or increasing tolerance Same solution

37 Changing the options for LP
Change the model Same solution 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
x1 x2 x3<= 1 x1 x2 x3>= 0 x1 x2 x3 int

41 Solving Capital Budget with Excel
italian english

42 Solving Capital Budget with Excel

43 Changing the options for ILP
Reducing time Reducing 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 Production costs Pliers are sold at 6 € each Spanners are sold at 5 € each Selling price How much should the factory produce to maximize its profit ? Objective function

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

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

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

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

50 A standard constraint: the budget one
Budget constraint: the overall cost must not greater than € 18000 CH = D8 = number of pliers PI = C8 = number of spanners CTOT= overall cost CTOT = 1  CH +1,5  PI Unit cost spanner Unit cost pliers Cost equation C11 = C5 * C8 + D5 * D8 CTOT = 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 budget constraint 1  CH + 1,5  PI = 18 Feasible region All non negative points “below” the line 1*CH + 1,5* PI = 18 12 CH PI 2 4 6 8 10 14 16 18 CTOT = 37500 > 18000: non ammissibile CTOT = CTOT = 7000  18000: ammissibile

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 CH 12 PI 2 4 6 8 10 14 16 18 1*CH + 1,5* PI = 18 Points in the red area satisfies the budget constraint, which is the better one ?

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

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
1 if project i is selected Definition of the decision variables xi= 0 if project i is not selected i=1,2,3 Definition of the objectives max 12 x1+8 x2+7 x3 earnings Definition of the constraints 8 x1+6 x2+5 x3 budget

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

57 Geometric view of the problem
Draw the line of the profit PTOT 4  CH + 4,5  PI For growing values of PTOT = PTOT = 72 12 CH PI 2 4 6 8 10 14 16 18 1*CH + 1,5* PI = 18 PTOT = 56 56 PTOT = 18 18 PTOT = 0 Growing direction Old best value Optimum !!

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

59 Geometric view of the technological constraint
0.001  CH  PI  14 1  CH + 1  PI  14000 14 PI 12 2 4 6 8 10 CH 16 18 1*CH + 1* PI = 14 hours 16 > 14: not feasible In the plane (PI, CH), first draw the equation of the technological constraint  14: feasible hours 6 Feasible region of the technological constraint

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
Hours: feasible Budget: not feasible Not feasible points PI 16 14 1*CH + 1* PI = 14 Hours: not feasible Budget: not feasible 12 1*CH + 1,5* PI = 18 10 8 6 Hours: not feasible Budget: feasible 4 2 Feasible set F Hours: feasible Budget: feasible 14 2 4 6 8 10 12 16 18 CH

62 Final feasible region 14 12 2 4 6 8 10 16 18 F 1  CH + 1,5  PI  18
budget hours Feasible solutions (CH,PI) satisfy: CH  0 PI  0 Non negativity 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

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

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

65 Graphical solution for LP
Let choice a feasible point PI CH 1  CH + 1,5  PI = 18 14 12 2 4 6 8 10 16 18 1CH + 1PI = 14 (4,4) (4000 spanners e 4000 pliers) PTOT = 34 The profit PTOT is 4CH + 4,5PI = 34 (34000 €) Better solution must have a value of PTOT  34 The idea is looking for solutions that satisfy also the “new fictitious” constrait 4CH + 4,5PI  34.

66 Graphical solution for LP
PI 1  CH + 1,5  PI = 18 14 12 2 4 6 8 10 16 18 1CH + 1PI = 14 CH 4  CH + 4,5  PI = 34 Draw the new feasible region F’ The profit PTOT is now 4CH + 4,5PI = 53 (53000 €) PTOT = 53 A better solution (if any) must be in the new feasible region F’ F’ Let choice (2,10). with Excel

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

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

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


Scaricare ppt "PER ANALISI DI SCENARI E OTTIMIZZAZIONE"

Presentazioni simili


Annunci Google