21
1 A Stochastic Optimization Case Study using ILOG CPLEX Concert Technology: Dual Sourcing Model for Managing Supply Chain Disruptions Vikas Argod Department of Mechanical Engineering, The Pennsylvania State University, University Park, PA 16802 Email: [email protected] Anshuman Gupta, PhD Research Computing and Cyberinfrastructure (RCC), Information Technology Services (ITS), The Pennsylvania State University, University Park, Pennsylvania 16802 Phone: 8148656081, Email: [email protected] A two stage stochastic programming model for incorporating demand uncertainty and disruptions in supply chain is described and implemented using ILOG CPLEX Concert Technology. Exchange rate variation is also considered along with other uncertainties for foreign supplier selection. The model is focused at setting up order portfolio minimizing total costs and helps in predicting the emergency orders. Management of financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods. 1. Introduction Continuous change, uncertain demand and intense competition are the defining characteristics of the today’s volatile business environment. In view of these conditions, meeting customers demand and making profit has become a challenge to supply chain managers. Most of the decisions have to be taken in highly uncertain environment. Operational and managerial flexibility are highly advocated in today’s supply chain. The uncertainty involved in most of these decisions can be linked to the basic structure underlying these activities, which is optimal usage of future resources on the basis of available present information and future scenarios 1 . In this age of globalization, supply chain is spread across countries. Especially developing countries are seen as main suppliers and exchange rate dynamics plays an important role in supplier selection. Corporations are using exchange rate variation for hedging supply chain risks 2 . But along with the higher profit due to selection of cheaper suppliers, risks of supply chain disruptions increase. As simple as uncertain lead time can affect the production plans which necessitates maintaining local supplier as a backup all times. Supply chain mangers have to optimize while selecting main supplier selection and also when placing orders for every planning horizon. In view of this observation, a versatile modeling and solution framework for aligning the internal planning decisions of a company under uncertainty is proposed in this study. Deterministic planning and scheduling models yield unrealistic results since it fails to recognize the effect of demand variability on the tradeoff between lost sales and inventory holding costs. Failure to consider stochasticity of future business conditions could lead to either unsatisfied

A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

1  

A Stochastic Optimization Case Study using ILOG CPLEX Concert Technology: Dual Sourcing Model for Managing Supply Chain Disruptions 

Vikas Argod Department of Mechanical Engineering,  The Pennsylvania State University, University Park, PA 16802 Email: [email protected]  Anshuman Gupta, PhD Research Computing and Cyberinfrastructure (RCC),  Information Technology Services (ITS),   The Pennsylvania State University, University Park, Pennsylvania 16802 Phone: 814‐865‐6081, Email: [email protected]  A  two stage stochastic programming model  for  incorporating demand uncertainty and disruptions  in  supply  chain  is  described  and  implemented  using  ILOG  CPLEX  Concert Technology. Exchange  rate variation  is also  considered along with other uncertainties for  foreign  supplier  selection.  The  model  is  focused  at  setting  up  order  portfolio minimizing  total costs and helps  in predicting  the emergency orders.   Management of financial risks  is also addressed by  linking  the optimization model with basic statistical and probabilistic methods. 

 

1. Introduction 

Continuous change, uncertain demand and intense competition are the defining characteristics of  the  today’s volatile business environment.  In view of  these  conditions, meeting  customers demand  and making  profit  has  become  a  challenge  to  supply  chain managers. Most  of  the decisions  have  to  be  taken  in  highly  uncertain  environment.  Operational  and  managerial flexibility  are  highly  advocated  in  today’s  supply  chain.    The  uncertainty  involved  in most  of these decisions can be linked to the basic structure underlying these activities, which is optimal usage of future resources on the basis of available present information and future scenarios1. In this age of globalization, supply chain is spread across countries. Especially developing countries are  seen  as main  suppliers  and  exchange  rate  dynamics  plays  an  important  role  in  supplier selection.   Corporations are using exchange  rate variation  for hedging supply chain  risks2. But along  with  the  higher  profit  due  to  selection  of  cheaper  suppliers,  risks  of  supply  chain disruptions  increase. As  simple  as uncertain  lead  time  can  affect  the production plans which necessitates maintaining  local  supplier  as  a  backup  all  times.  Supply  chain mangers  have  to optimize while selecting main supplier selection and also when placing orders for every planning horizon.  In view of  this observation, a versatile modeling and  solution  framework  for aligning the  internal  planning  decisions  of  a  company  under  uncertainty  is  proposed  in  this  study. Deterministic planning and scheduling models yield unrealistic results since  it fails to recognize the effect of demand variability on the tradeoff between lost sales and inventory holding costs. Failure  to  consider  stochasticity of  future business  conditions  could  lead  to either unsatisfied 

Page 2: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

2  

customers  causing  loss  of  market  share  or  high  inventory  holding  costs2.  Hence,  following stochastic programming is justified.  

There  are  lots  of  publications  available  addressing  general  issues  of  supply  chain  risk management  focusing  on  demand  uncertainty.  There  are  some  articles  focusing  precisely  on disruptions and they suggest various ways of have safer supply chains and different methods of mitigating the consequences of disruptions.4 Lee and Wolfe5 suggest a  list of possible methods to design supply chain with flexible sourcing strategies like developing multiple supply sources, maintaining  local  supplier with  constant  orders  at  all  normal  times  etc.  Single  sourcing  has allowed to reduce the sourcing cost and resulted in better quality, but this approach is risky. So, it is advisable for firms to consider multiple sourcing approaches to cover against disruptions in supply chain. In order to make choice between these two approaches, concept of real options is used by various  literatures  to evaluate and  take  into account  flexibility1. Piaw6  laid down  the comparison  between  single  sourcing  and  multiple  sourcing  considering  Kraljic’s  portfolio approach of 4 types of commodities, which leads to differentiated purchasing strategies. Cohen and  Huchzermeier  showed  how  operational  flexibility  can  be  captured  effectively  through stochastic recourse (whereby the firm can respond to random outcomes by changing decisions). Newsvendor problem is one of simplest form of planning under demand uncertainty. McDonald and  Karimi7  proposed  midterm  planning  model  with  capacitated  lot‐sizing  problem. Deterministic formulation can be found in Gupta and Maranas8. MIT Research group on “Supply chain response to Global terrorism” (2003) have shown that firms usually focus on the type of disruption  and  not  its  source  for  securing  the  supply  chain.  They  distinguish  6  types  of disruptions:  disruptions  in  supply,  transportation,  at  facilities,  freight  breaches,  in communication, and in demand. 

The rest of paper  is organized as follows.  In the next section, general modeling considerations are explained followed by explanation of the model developed. Risk management strategies are given.  Implementation  methodology  using  CPLEX  solver  invoked  using  C++  API  is  briefly explained.    Result  for  a  simple  case  study  is  discussed  for  the  completeness  of  the model. Methodology of approximating normal distributions by discrete ones and CPLEX code are given in the Appendix. 

2. Modeling  the decision making process 

An  important  component  of  decision  making  under  uncertain  conditions  is  the  way  of representing stochastic parameters. There are two distinct ways of incorporating uncertainty. In scenario  based  approach9,  a  random  parameter  is  considered  with  all  its  possible  future outcomes. The main disadvantage of  this  technique  is  that  the  size of  the problem  increases exponentially  with  the  increase  in  the  number  of  scenarios.  To  overcome  this  difficulty, continuous probability distributions  for  the  random parameters are often used.10 It  introduces nonlinearities in the problem but decrease the size of the problem. In this study, scenario based approach is used. Product demand and disruptions are modeled as normally distributed random variables. This approach has been widely  invoked  in  the  literature as  it captures  the essential 

Page 3: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

3  

features of demand uncertainty and it is convenient to use. In the two stage stochastic approach considered, there are two sets of decision variables. The first stage variables, sometimes known as  design  variables,  correspond  to  decisions  that  need  to  be  made  prior  to  resolution  of uncertainty  (“here‐and‐now”  decisions).  Based  on  the  realization  of  the  random  events,  the second‐stage or  control decisions  are made  according  to  the  restrictions of  the  second‐stage recourse problem  (“wait‐and‐see” decisions). The uncertainty  is  translated  into  the  stochastic nature of  the  costs  related  to  second‐stage variables. Hence, objective  function  comprises of first  stage decision  costs  and  expected  recourse  cost.    The problem of  increasing  size of  the problem  with  the  increase  in  the  number  of  scenarios  is  well  answered  by  Dantzig‐Wolfe Decomposition11  and  Benders  decomposition12.  For  continuous  probability  distributions,  this challenge  has  been  taken  care  by  explicit/implicit  discretization  of  probability  space  for approximating multivariate probability  integrals13.  In  the model which will be explained  in  the next section first stage cost  is also an expected cost which consists of exchange rate variation. But  the  demand  and  disruption  scenario  are  resolved  in  second  stage when  exchange  rate calculations are already over. Supply chain managers need to select the supplier considering the effect of exchange rate variation and order has to be placed in advance such that sufficient time is  available  in  order  to  rectify  the  effect  of  supply  chain  disruptions with  the  help  of  local suppliers.  

3. Dual Sourcing model with supply chain disruptions 

The problem addressed in this study can be stated as follows:  

Given a set of candidate foreign suppliers (main suppliers) characterized by their respective cost with exchange  rate dynamics, demand    scenarios, disruption  scenarios as percentage of order received  from  main  supplier,  local  supplier  with  minimum  and  maximum  orders  and  costs associated with  it,  inventory  holding  cost,  inventory  limit,  normal  and  emergency  production costs, determine the supplier to be chosen, optimum order to main supplier and order portfolio‐that minimizes the total expected cost.  Sets  

J = { j } = Set of candidate foreign suppliers K1= { k1} = Set of demand scenarios K2 = { k2} = Set of exchange rate scenarios K3 = { k3} = Set of disruption scenarios 

                  Parameters    

  cjnor =  Cost per product by supplier j 

  clocal = Cost per product  by local supplier   cback = Back order cost   h = Inventory holding cost   I0 = Inventory limit   cp

nor= Normal production cost   cp

eme= Emergency  production cost   Θk1= Demand in scenario k1 

Page 4: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

4  

  ωΘk1= Probability of demand scenario k1 

  Ek2j= Exchange rate in scenario k2j   ωE

k2j= Probability of demand scenario k2j   Qmin

local= Minimum order to local supplier   Qmax

local= Maximum order to local supplier         dk3= percentage of order supplied by the main supplier in disruption scenario k3   ωd

k3= Probability of disruption scenario k3  

   Variables 

     Yj = 1 if Supplier j is chosen; 0 otherwise   Qj

0= Order placed with supplier j   QL

0= Order placed with local supplier   Qk1k3

eme= Emergency order in demand scenario k1 and disruption scenario k3                Ik3= Inventory in disruption scenario k3 

Bk1k3exe=  Backorder  observed  after  demand  is  realized  and  ordering  emergency  products  in 

demand scenario k1 and disruption scenario k3  Utilizing the above‐described notations, the Basic Dual Sourcing  (BDS) model  is  formulated as follows.  (BDS)  

   min   ∑ ∑               

12

       

  

  Subject to          ∑ 1           (1)          ∑                        (2)      

        max 0,        ,      (3) 

         ,                                           (4)                                          max 0,        ,                          (5)              0                                                                             (6)        0,1 ,     0,      0                                              (7)  

Page 5: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

5  

          

In the considered approach, a stage corresponds to the description of the system,  in  terms of the variables and constraints, between two points of uncertainty resolution.  In the considered framework, “here‐and‐now” decisions are supplier  selection  (Yj)  ,  initial order placed with  the supplier j  (Qj0)and initial order to the local supplier (QL

0). The costs incurred in this stage include the  initial ordering  cost with both  the  suppliers  (first  and  second  term).  In  the  case of main supplier, expected cost due  to exchange  rate variation  is calculated.   Selecting only one main supplier from the pool of available suppliers is ensured by eq 1. After the initial order, first level of uncertainty is resolved as the disruption scenario comes into picture. Due to disruption, only dk3  times  Qj0  is  supplied  by  the main  supplier  while  local  supplier  supplies  whatever  order placed. Hence inventory is given by eq 2. Inventory holding cost is indicated in the fifth term of objective function. (Average inventory cost is considered, for simplicity). Uncertainty in product demand is resolved at this stage and  it calls for emergency orders from local supplier. Demand uncertainty  also  affects  the  bottom  line  of  the  firm  through  variable  production  costs,  as accounted by third and fourth term in the objective function equation. Higher cost incurred due to emergency orders and production is reflected in sixth term of objective function. Once all the uncertainties are resolved, emergency order is calculated by eq 3, while bounds on order placed with  the  local  supplier  at  all  levels  are  enforced  through  eq  4.    is  the  “wait‐and‐see” decisions , hence it establishes the order portfolio. Excess backorder if any, which was not met even at the end (may be due to the fact that order to local supplier was greater than maximum limit) is determined through eq 5 and respective cost is taken into account through the last term in the objective function. Firm has an inventory limit which is enforced through eq 6.       A  scenario –based description of both demand and disruption  forms  the basis of  the above described model.  The  nonanticipative14  resolution  of  these  uncertainties  can  be  represented through scenario tree.  Nonanticipativity implies that all the inner stage decisions are based on the  actual  values  realized  by  all  uncertain  parameters  that  are  preceding  that  decision.  This means that  inner decision variables depend on the entire history of the process of uncertainty resolution.   For example, emergency order  in  last stage depends on the disruption observed  in stage two and demand scenario observed in stage three.  This nonanticipativity characteristic is captured by the diverging scenario tree. This is the main reason for exponential increase in the number  of  overall  scenarios  with  the  number  of  individual  scenarios.  A  stage  is  formed wherever  branching  occurs15,  while  each  branch  of  the  tree  corresponds  to  a  particular realization of demand and disruption uncertainty. Cost associated with each branch is different which  causes  a distribution of  total  cost  at  the end of planning horizon. Minimization of  the expected cost of this distribution is achieved by probabilities of demand and disruption scenario through the objective function of the BDS model.  

4. Risk Management   

The central idea of any risk management is the incorporation of the classic tradeoff between risk  and  return within  the  framework  of decision process15. As  formulated, BDS model  takes purely expected cost‐minimization perspective; hence it assumes that the firm is risk‐neutral. In general, firms prefer lower, as opposed to high variability of the cost for a given value of return. Consequently, controlling variability is well recognized in the financial community mainly when firm  deals  with  portfolio  management  applications.16  Variance  in  returns  is  widely  used  in financial  decision  making  in  corporate  policy  formulation  settings.17.  But  variance  being  a 

Page 6: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

6  

symmetric measure of  the dispersion  of  the  actual  cost  around  the mean,  a  reduction  in  its value decreases downside  risk but  it decreases upside potential.  In  view of  this  limitation,  in literature  there are different approaches. A probabilistic approach and  limit on  the maximum cost is implemented in the current framework.  In the former approach, probability that cost at any scenario (TC) is controlled by the addition of following constraint in the model description. 

       Pr                                                (8)  This  ensures  that  the probability of  the  total  cost  (TC)  in  every  scenario  exceeding  some 

maximum  cost  ( )  is  less  than  some  specified  level  ( ).  Using  this  probabilistic  constraint within the current model framework requires an additional binary variable defined as follows. 

 

                                                   1     0     

                                                (9) 

   

        ∑ ∑                  

          12      

                                   (10)          Addition of following set of constraints enforces the probabilistic constraint explained                     1 1      (11)            ∑                                      (12)      where M is an upper bound on the total cost TC.     

The probabilistic approach described above has an added complexity associated with additional  binary variables. In light of this increasing complexity, a more computationally better approach which targets the worst‐case cost scenario can be implemented by adding following constraint.          max                                                (13)                                                        or                                                                                  (14)   With  this  approach,  the  formulation  becomes  computationally  less  expensive  and  risk elimination criteria are also met. 

  

Page 7: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

7  

5. Implementation and solution using ILOG CPLEX Concert Technology 

     The model is implemented in C++ using CPLEX Concert Technology.  Concert Technology is a set  of modeling  objects  that  allow  a  high‐level  representation  that mirrors  the  optimization model’s  algebraic  representation.  Since  CPLEX  can  solve  linear  problem  and  the  presented 

model  involves  nonlinearity  (observe     0 ),  linearization  procedure  is  used.  Literature 

describes various methods of  linearization  for 0‐1 polynomial programs.   This  introduces one more set of binary variables and constraints as follows. 

 

                                                                                              (15) 

                                                1   1               (16) 

                          0,1                                                     (17) 

 

  Thus,    can be replaced with   in the model described above thereby making it linear   which can be extracted and solved using CPLEX.  

One more interesting constraint is eq 3 which is a max constraint (eq 5 is also similar). This was implemented using “IloMax” operator available in CPLEX. As per the available documentation, syntax of IloMax is as follows18.  public IloNumToNumStepFunction IloMax(const IloNumToNumStepFunction f1, const IloNumToNumStepFunction f2) This operator creates and returns a function equal to the maximal value of the functions f1 and f2. Usage of this operator was also cross checked with two greater than constraints and found consistency in the results. Scenarios were created by approximating continuous distributions of the random variables by discrete ones.19 Explanation of this method is given in the Appendix‐A. A  standalone C++  code  created  this  realizations  and writes  to  an ASCII  file which  is  taken  as input by the CPLEX Concert Technology code. All C++ codes are given  in the Appendix‐B with a sample input file. 

 6. Case Study

 A manufacturing/assembly firm  is  in  its starting phase of planning horizon.  It has to select one main supplier from available two different suppliers. Since the price quoted by the suppliers will not take  into account of exchange rate variation, decision should consider the best price case. The parameters characterizing each  supplier, production charges, and demand and disruption variations  are  listed  in  Table  1.  Note  that  all  cost  parameters  are  assumed  to  be  relative monetary units (RMU) while demand levels are relative product units (RPU).    

Page 8: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

8  

20 scenarios of each of the distributions are considered for the case study. This results in around 428 variables and 2455 constraints. It is to be noted that this size increased exponentially as the number of scenarios  increase. This was solved  in one of Penn state clusters, Hammer  (64 bit, AMD Opteron processor). It took approximately 8 CPU s. Solution of this model is given in Table 2 and distribution of emergency order is given in Figure 1. The cheaper cost of main supplier is exploited and initial order is placed taking into account of disruptions. Probability of emergency order to the local supplier below 100RPUs is about 60%. Rest of the cases is higher emergency orders with very less probabilities.  This is clear from the Figure 1.           Next, the  impact of proposed risk management techniques on the risk scenarios of the firm  is studied.  The  results  obtained  for  probabilistic  methods  and  worst  case  cost  control  are presented  in  Figure  2‐3,  respectively.  The  tradeoff  curves  are  shown  in  these  figures  are obtained by first appending the corresponding risk management constraints to the BDS model followed by parametrically varying the appropriate risk metric. 

 Table 1. Parameter values used for the case study 

 Parameter  Value 

cjnor  [10,9]

clocal 25 cback  200 H 15 I0  20,000 cp

no  50 cp

eme 125 Θ  Normal(1500,100) Ek21( Exchange rate for supplier 1) Uniform(0.71,0.93) Ek22( Exchange rate for supplier 2) Uniform(0.7,1.1) Qmin

local, Qmaxlocal 100, 150000

dk3 Normal(0.8,0.1) Table 2. Result of the case study  

 Variable  Value 

Supplier Selected  2nd 

Initial order placed with that supplier  1756.03 (RPU) 

Net Expected cost  119341 (RMU) 

Initial order to local supplier  100 (RPU) 

Maximum cost in the distribution  175259 (RMU) 

 The conclusion is based on the observation that, as the risk metric decreases, expected cost increases which is obvious from the principles from Economics. In the current setting, expected cost increases or profit decreases for low risk cases.  

Page 9: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

9  

  

Figure 1. Emergency order distribution 

      Figure 2.Variation of the total expected cost with the probability level 

 

 Figure 3.Variation of the total expected cost with the worst‐case 

 total cost scenario  

7. Summary 

0%

10%

20%

30%

40%

50%

60%

70%

30.3 90.9 151.5 212.2 272.7 333.3 393.9 454.5 515.1 575.7

Prob

ability

Emergency orders

113000

114000

115000

116000

117000

118000

119000

120000

0% 1% 2% 3% 4% 5% 6%

Expe

cted

 cost

Probability level 

100000

105000

110000

115000

120000

125000

130000

135000

140000

140000 150000 160000 170000 180000 190000

Expe

cted

 cost

Worst case total cost scenario

Page 10: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

10  

 In  this work,  the  supplier  selection  and  initial order  calculation problem  faced by  a  firm was addressed.  In particular, this work focused on the incorporation of these three following issues in  the planning process:  (1)  Inclusion of exchange  rate  variation while  selecting  suppliers,  (2) inclusion  of  supply  chain  disruptions  and  demand  uncertainty  and  (3)  risk management  for reducing cost variability.  A  multistage  stochastic  programming  approach  was  considered  for  studying  demand  and disruption uncertainties in the decision making process.  The partitioning of decision phases into “here‐and‐now”  and  “wait‐and‐see”  provided  the  appropriate  structure  of  stochastic  stage formulation. More  importantly,  supplier  selection  and  initial  order  to  the main  supplier was made  prior  to  realizations  of  uncertainties  involved  in  the  framework.  The  issue  of  actively managing the risk exposure of the firm was also addressed. Two alternate approaches namely (1)  probabilistic  approach  and  (2)  worst‐case  total  cost  for  limiting  the  downside  risk maintaining  the upside potential. To highlight  the effectiveness and validity of  the developed model, it was applied to a planning case study. Risk management techniques were also used in this case study.   In  conclusion,  future work  on  the  problem  addressed  in  this work  could  proceed  in  several different  directions.  The model  could  be  extended  to  a multiperiod  setting  where  supplier selection and ordering depends on many periods. Usually, there will be supplier changing cost and  local supplier quotes different price for different percentage of  initial order. This model  is from the side of firm while sudden variation in the demand for local supplier is not studied. The same model  can be  extended  to  studying  impact of  exchange  rates  in  case of demand  from many countries thereby using exchange rate dynamics to hedge the supply chain risks. Finally, the proposed model could also be integrated with contracts with suppliers for studying the cost saving compared to the present system of dual suppliers. 

 

  References: 

1. Gupta A and Maranas, C.D. “Real‐Options‐based planning strategies Under Uncertainty”. Ind. Eng.Chem Res. 2004, 43, 3870‐3878 

2. Cohen M.A and Huchzermeier. A, “Global supply chain network management under price/exchange rate risk and demand uncertainty". 

3. Petkov, S. B.; Maranas, C. D. “Multiperiod Planning and Scheduling of Multiproduct Batch Plants under Demand Uncertainty”. Ind. Eng. Chem. Res. 1997, 36, 4864. 

4. Pochard S, “Managing risks of Supply chain disruptions: Dual sourcing as a real option”. Massachusetts Institute of Technology, August 2003 

5. Lee, H.L., Wolfe, M.  “Supply Chain Security without Tear”, Supply Chain Management Review, January‐February, 2003. pp 12‐20. 

6. Piaw. T.C. “Purchasing and Supply chain management: Supplier management”. National University of Singapore.  

7. McDonald, C ; Karimi, I.A. “Planning and Scheduling of parallel semi continuous processes” Ind. Eng. Chem. Res 1997,36,2691 

Page 11: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

11  

8. Gupta A, ;Maranas, C. D. “A hierarchical lagrangean relaxation procedure for solving midterm planning problems” Ind. Eng. Chem. Res 1999,38,1937 

9. Liu, M. L.; Sahinidis, N. V.“Long Range Planning in the Process Industries: A Projection Approach”. Comp. Oper. Res. 1996, 23, 237. 

10. Ierapetritou, M. G.; Pistikopoulos, E. N. “Batch plant design and operations under uncertainty.” Ind. Eng. Chem. Res. 1996, 35, 772. 

11. Dantzig, G. B.; Wolfe, P. “The decomposition principle for linear programs”. Oper. Res. 1960, 8, 101. 

12. Benders, J. F. “Partitioning procedures for solving mixed variables programming problems.” Numer. Math. 1962, 4, 238. 

13. Straub, D. A.; Grossmann, I. E. “Integrated stochastic metric of flexibility for systems with discrete states and continuous parameter uncertainties”. Comp. Chem. Eng. 1990, 14, 967. 

14. Birge J.R,; Louveaux, F. “Introduction to Stochastic Programming”, Springer: New York 1997 15. Gupta A,;Maranas C.D “Market Based Pollution abatement strategies : Risk management using 

emission option contracts”. Ind. Eng. Chem Res 2003, 42, 802‐810 16. Luenberger, D.G. “Investment Science”, Oxford University Press: New York 1998 17. Damodaran, A. “Corporate Finance: Theory and practice”. John Wiley: New York 1998 18. http://terra.rice.edu/comp.res/apps/c/cplex/docs/refconcert/html/functions/IloMax.html 19. Peter Kall,; Stein W. Wallace. “Stochastic Programming” . First edition, John Wiley & Sons. 

‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 

Appendix –A 

Discretizing the normal distribution19 

 

If any random variable is following normal distribution, taking expected value is cumbersome if multivariate numerical integration is used. To avoid this difficulty, normal distribution can be approximated by discrete ones. Methodology for discretization is given below: Consider a random variables δi (i=1,2) which are normally distributed 1. Generate large samples δi

μ, μ=1,2….K, i=1,2, restricted to may be 99% intervals of the given distribution. Sample size K=100000 (say) 

2. Choose equidistant partitions of the 99% intervals into ri, i=1,2 subintervals. (e., r1= r2=15) 3. Calculate for every subinterval Iiv, v = 1…ri, i=1,2, the arithmetic mean , Mi

v of the sample values δi

μ Є Iiv, yielding an estimate for the conditional expectation of δi and Iiv 

4. Calculate for every subinterval Iiv the relative frequency piv  for δiμ Є Iiv (i.e, piv = kiv/K, where k‐

iv is the number of sample values δiμ  contained in Iiv). This yields an estimate for the 

probability  of {δiμ Є Iiv+}. 

The discrete distributions, {( Mi

v,piv), v= 1,,…..ri}, i=1,2 are can be used as approximation for 

the given normal distributions.  Following figure shows these discrete distributions for N(0,12) and N(0.9) with 15 realizations each. 

Page 12: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

12  

 ( Source: reference # 19) 

Appendix –B CPLEX implementation and generation of input file 

 

CPLEX code with probabilistic approach of risk management:dual.cpp #include <ilcplex/ilocplex.h> #include <math.h> #include <iostream> #include <fstream> ILOSTLBEGIN typedef IloArray<IloNumVarArray> IloNumVarArray2; int main(int argc, char **argv) { IloEnv env; try {

const char* filename = "dual_source.dat"; //input file if (argc >= 2) filename = argv[1]; ifstream file(filename); if( !file) { cerr << "No such file : " << filename << endl; throw(-1); } char dummy[100]; // dummy variable for reading comments in input file IloInt num_sup; //number of suppliers IloNum c_eme,c_back,h,I0,cp_nor,cp_eme,Q_max, TC_hat,alpha,QL_min,c_local;

Page 13: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

13  

IloNumArray theta(env),c_nor(env),w_t(env),d(env),w_d(env);//parameters IloNumArray2 E(env),w_e(env); file >> dummy >> num_sup // reading the input fil >> dummy >> c_nor >> dummy >> c_local >> dummy >> c_back >> dummy >> h >> dummy >> I0 >> dummy >> cp_nor >> dummy >> cp_eme >> dummy >> theta >> dummy >> w_t >> dummy >> d >> dummy >> w_d >> dummy >> E >> dummy >> w_e >> dummy >> QL_min >> dummy >> Q_max >> dummy >> TC_hat >> dummy >> alpha; IloInt sup_num_check = c_nor.getSize(); // some error checks IloInt demand_size = theta.getSize(); IloInt theta_size = w_t.getSize(); IloInt dis_size = w_d.getSize(); if(sup_num_check != num_sup || demand_size !=theta_size) { cerr << " ERROR: Inconsistant Data " << endl; throw(-1); } IloInt j,k1,k2,k3; // different varibales for loops, printing etc IloNum Q_final,M,z,k; IloModel mod(env); M = 10000000.0; // BIG M : upper bound of Z, continuous variable of linearisation for(j=0; j<num_sup; j++) // error checking for E and its probability { if(E[j].getSize()!= w_e[j].getSize()) { cerr << " ERROR: Inconsistant Data for Exchanage rate scenario "<<endl; throw(-1); } } //Variables IloNumVarArray y(env,num_sup,0.0,1.0,ILOBOOL); //boolian variable for Supplier selection IloNumVarArray Q(env,num_sup,0.0,M); // Order placed with supplier j IloNumVarArray Z(env,num_sup,0.0,IloInfinity); // Continuous variable on account of //linearization IloNumVarArray ini_inv(env,dis_size,0.0,I0);

Page 14: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

14  

IloNumVarArray2 Q_eme(env),B_exe(env),tc(env),Za(env); for (k1=0; k1<demand_size; k1++) {

Q_eme.add(IloNumVarArray(env,dis_size,0.0,IloInfinity)); //emergency shipments B_exe.add(IloNumVarArray(env,dis_size,0.0,IloInfinity)); //backorder

tc.add(IloNumVarArray(env,dis_size,0.0,TC_hat)); Za.add(IloNumVarArray(env,dis_size,0.0,1.0,ILOBOOL)); } IloNumVar QL(env,QL_min,Q_max); //Objective IloExpr sup_cost(env),local_cost(env),prod_cost(env),inv_cost(env),uncertain_cost(env); for (j=0; j<num_sup; j++) //supplier cost for(k2=0; k2<E[j].getSize(); k2++) sup_cost += (w_e[j][k2]*E[j][k2]*c_nor[j]*Z[j]); local_cost = QL*c_local; for (k3=0; k3<dis_size; k3++) for (j=0; j<num_sup; j++) //production cost prod_cost +=w_d[k3]*d[k3]*cp_nor*Z[j]; prod_cost += cp_nor*QL; for(k3=0;k3<dis_size; k3++) inv_cost += w_d[k3]*0.5*h*ini_inv[k3]; //inventory cost for (k3=0; k3<dis_size; k3++) for (k1=0; k1<demand_size; k1++) //uncertain cost due to demand variation

uncertain_cost += w_d[k3]*w_t[k1]*(Q_eme[k1][k3]*(c_local+cp_eme) + B_exe[k1][k3]*c_back);

mod.add(IloMinimize(env,sup_cost+prod_cost+local_cost+inv_cost+uncerta in_cost));

sup_cost.end(); prod_cost.end(); inv_cost.end(); uncertain_cost.end(); local_cost.end(); //Constraints IloExpr sup_cnst(env); //only one supplier is chosen for (j =0; j<num_sup; j++) sup_cnst += y[j]; mod.add(sup_cnst == 1); sup_cnst.end(); for (k3=0; k3<dis_size; k3++) { IloExpr inv_cnst(env); //inventory limit at any point for (j=0; j<num_sup; j++)

Page 15: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

15  

inv_cnst += d[k3]*Z[j]; inv_cnst += QL; mod.add(ini_inv[k3] == inv_cnst); inv_cnst.end(); }

for (j=0; j<num_sup; j++) //linearising { mod.add(Z[j] <= M*y[j]); mod.add(Q[j]- M*(1-y[j]) <= Z[j] <= Q[j]); } for (k3=0; k3<dis_size; k3++) for (k1=0; k1<demand_size; k1++) //Emergency order calculation {

mod.add(Q_eme[k1][k3] == IloMax(0.0,(theta[k1]-ini_inv[k3]))); mod.add(Q_eme[k1][k3] <= Q_max);

mod.add(B_exe[k1][k3] == IloMax(0.0,(theta[k1]-ini_inv[k3]- Q_eme[k1][k3])));

} IloExpr first_stage(env); for (j=0; j<num_sup; j++) { for (k2=0; k2<E[j].getSize(); k2++) first_stage += (w_e[j][k2]*E[j][k2]*c_nor[j]*Z[j]); } first_stage += QL*(c_local+cp_nor); for (k3=0; k3<dis_size; k3++) { for (k1=0; k1<demand_size; k1++) { IloExpr TC(env),disruption_cost(env); for (j=0; j<num_sup; j++) disruption_cost += cp_nor*d[k3]*Z[j]; disruption_cost += 0.5*h*ini_inv[k3];

TC = first_stage + disruption_cost + Q_eme[k1][k3]*(c_local+cp_eme) + B_exe[k1][k3]*c_back;

mod.add(TC >= TC_hat - M*(1-Za[k1][k3])); mod.add(TC <= TC_hat*(1-Za[k1][k3]) + M*Za[k1][k3]); TC.end(); uncertain_cost.end(); } } first_stage.end(); IloExpr prob(env); for (k3=0; k3<dis_size; k3++) for (k1=0; k1<demand_size; k1++) prob += w_t[k1]*w_d[k3]*Za[k1][k3]; mod.add(prob <= alpha); prob.end(); IloCplex cplex(mod);

cplex.exportModel("dual_source1.lp"); //writing lp file

Page 16: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

16  

std::ofstream out("dual_source.results"); //output file out << endl << "Minimum Cost = " << cplex.getObjValue() << endl; env.out() << endl << "Minimum Cost = " << cplex.getObjValue() << endl; for (j=0; j<num_sup; j++) { z = cplex.getValue(Z[j]); k = cplex.getValue(y[j]); if( z !=0.0) { out << endl << "Supplier choosen and the order placed\t"; env.out() << endl << "Supplier choosen and the order placed "; out << "j= " << j+1 << "\tQ = " << z << endl; env.out() << " j = " << j+1 << "\tQ = " << z << endl;

out << "Initial Order with the local supplier:\t" << cplex.getValue(QL) <<endl; env.out() << "Initial Order with the local supplier:\t" << cplex.getValue(QL) <<endl;

break; } else if(j== num_sup-1) {

out << "\n Emergency ordering is prefered..dual sourcing-> single sourcing "<<endl; env.out() << "\n Emergency ordering is prefered.. dual sourcing-> single sourcing " <<endl;

} } IloExpr add_cost(env); for (j=0; j<num_sup; j++) //supplier cost { for(k2=0; k2<E[j].getSize(); k2++) add_cost += (w_e[j][k2]*E[j][k2]*c_nor[j]*Z[j]); } add_cost += QL*(c_local);

out << endl << "k3\tk1\tprob\tOrder recieved\tDemand\t\tEmergency Order\tI- cost\t\tII-cost\t\tTotal Cost" <<endl;

for (k3=0; k3<dis_size; k3++) for (k1=0; k1<demand_size; k1++) { IloExpr tc,dis_cost(env),tc2,rece_order(env); for (j=0; j<num_sup; j++) { dis_cost += cp_nor*d[k3]*Z[j]; rece_order += d[k3]*Z[j]; } dis_cost += 0.5*h*ini_inv[k3] + QL*cp_nor;

tc2 = dis_cost +(Q_eme[k1][k3]*(c_local+cp_eme) + B_exe[k1][k3]*c_back);

tc = add_cost + tc2; out << k3 << "\t" << k1 <<"\t" << w_t[k1]*w_d[k3] << "\t"

<< cplex.getValue(rece_order) << "\t\t" << theta[k1] << "\t\t"

Page 17: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

17  

<< cplex.getValue(Q_eme[k1][k3]) << "\t\t" << cplex.getValue(add_cost) << "\t\t" << cplex.getValue(tc2) << "\t\t" << cplex.getValue(tc) << endl; tc.end(); dis_cost.end(); rece_order.end(); tc2.end(); } add_cost.end(); } catch(IloException& ex) { //for any exceptions caught cerr << "Error : " << ex << endl; } catch(...) { cerr << "Error : Unknown exception caught!" << endl; } env.end(); return 0; }

C++ code for input file generation:dual-input.cpp #include "randomlib1.h" #include <iostream> #include <fstream> #define N 100000 #define M 25 /* Read readme.txt before getting confused with anything in the program*/ using std::cout; using std::cin; using std::endl; void set_zero(double[][N],int, int); int main() { //declaration of variables double lower[M],upper[M], //lower and upper limits mean[M],stddev[M], //mean and standard deviation sum[M][N],binn[M][N], //sum for each bin and # of #'s in bin bin_size[M],binl[N],binu[N], //size of the bin, limits of the bin ran,rann,f[N],cost[M]; //random number generated, mean of the bin, frequency int s,size, //# of distributions, sample size i,j,k,si,sj; //some variables, seed for RNG int n[M],choice[M]; char dummy[128];

Page 18: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

18  

//open the input and then output file std::ifstream in("dual_source.in"); std::ofstream out("dual_source.dat"); in >> dummy >> s; for (i=0; i<s; i++) in >> dummy >> choice[i] >> mean[i] >> stddev[i] >> lower[i] >> upper[i] >> n[i]; in >> dummy; for (i=0; i<s-2; i++) in >> cost[i]; in >> dummy >> size >> dummy >> si >> sj; in.close(); //initialization set_zero(sum,s,N); set_zero(binn,s,N); /* Make sure the initialisation routine has been called */ if (!test) RandomInitialise(si,sj); // start the real work for (i=0; i<s; i++) { bin_size[i] = (upper[i]-lower[i])/(float)n[i]; k = 0; binl[k] = lower[i]; for (k=0; k<n[i]; k++) { binu[k] = binl[k] + bin_size[i]; if(k !=(n[i]-1)) binl[k+1] = binu[k]; } j = 0; while (j!=size) { if(choice[i] == 1) ran = RandomGaussian(mean[i],stddev[i]); else ran = RandomDouble(lower[i], upper[i]); for (k=0; k<n[i]; k++) { if(ran > binl[k] && ran < binu[k]) { j++; sum[i][k] = sum[i][k]+ran; binn[i][k] = binn[i][k]+1; } } } }

Page 19: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

19  

out << "*Number_of_suppliers\n" << (s-2) << "\n" << "*C_normal\n" << "["; for (i=0;i<s-2; i++) { if (i !=s-3) out << cost[i] << ","; else out << cost[i] << "]\n"; } out << "*C_local\n" << "25\n" << "*C_back\n" << "200\n" << "*inventory_holding_h\n" << "15\n" << "*inventory_limit\n" << "20000\n" << "*C_prod_normal\n" << "50\n" << "*C_prod_emergency\n" << "125\n"; i = 0; // Writing Demand realization and disruptions for (i=0; i<2; i++) { if (i==0) out << "*theta\n"; else out << "*disruptions\n"; for (k=0; k<n[i]; k++) { rann = sum[i][k]/binn[i][k]; f[k] = binn[i][k]/size; if(k==0) out << "[" << rann << ","; else if(k<n[i]-1) out << rann << ","; else out << rann << "]" << endl; } if (i==0) out << "*w_theta-k1\n"; else out << "*w_d-k3\n"; for (k=0; k<n[i]; k++) { if(k==0) out << "[" << f[k] << ","; else if(k<n[i]-1) out << f[k] << ","; else out << f[k] << "]" << endl; } } out << "*E-k2\n" << "["; for (i=2; i<s; i++) { for (k=0; k<n[i]; k++) { rann = sum[i][k]/binn[i][k]; f[k] = binn[i][k]/size; if(k==0) out << "[" << rann << ","; else if(k<n[i]-1) out << rann << ","; else if(i==s-1) out << rann << "]"; else out << rann << "],"; } } out << "]\n*w_theta-k1\n["; for (i=2; i<s; i++) { for (k=0; k<n[i]; k++) { rann = sum[i][k]/binn[i][k]; f[k] = binn[i][k]/size;

Page 20: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

20  

if(k==0) out << "[" << f[k] << ","; else if(k<n[i]-1) out << f[k] << ","; else if(i==s-1) out << f[k] << "]"; else out << f[k] << "]," ; } } out << "]\n*QL_max\n" << "100" <<"\n*Q_max\n15000" << "\n*TC_hat\n" << "250000" << "\n*alpha\n" << "0.1" << endl; out.close(); } void set_zero(double setting[][N],int m,int n) { int i,j; for (j=0; j<m; j++) { for (i=0; i<n; i++) setting[j][i] = 0; } } Input file for the CPLEX code: *Number_of_suppliers 2 *C_normal [10,9] *C_local 25 *C_back 200 *inventory_holding_h 15 *inventory_limit 20000 *C_prod_normal 50 *C_prod_emergency 125 *theta [1217.2,1247.12,1276.66] *w_theta-k1 [0.1,0.8,0.1] *disruptions [0.8,0.7,0.9] *w_d-k3 [0.15,0.75,0.1] *E-k2 [[0.878488,0.901713,0.924972],[0.999965,1.03996,1.07997]] *w_theta-k1 [[0.33,0.33,0.33],[ 0.33,0.33,0.33]] *QL_max 100

Page 21: A Stochastic Optimization Case Study using ILOG CPLEX ... · financial risks is also addressed by linking the optimization model with basic statistical and probabilistic methods

21  

*Q_max 15000 *TC_hat 145000 *alpha 0.01