Modeling stochastic programming problems in Supply chain

0 downloads 0 Views 973KB Size Report
Supply chains continually face the challenge of efficient decision-making in a complex environment ... timelines, production costs and lead times, and improve quality. ... overhead, such as amount of resources, man-power, inventory, and lead to a failure to ...... whereµ and are the unconditional mean and the variance of. 2 σ.
Modeling & Solving Stochastic Programming Problems in Supply Chain Management using Xpress-SP1 Alan Dormer (email: [email protected])

Alkis Vazacopoulos (email: [email protected])

Nitin Verma (email: [email protected])

Horia Tipi (email: [email protected])

Dash Optimization, Inc 560 Sylvan Avenue, Englewood Cliffs, NJ 07632

Abstract Supply chains continually face the challenge of efficient decision-making in a complex environment coupled with uncertainty. While plenty of forecasting and analytical tools are available in the market to evaluate and enhance Supply Chains’ performance, the current functionalities are not sufficient to address issues related to efficient decision making under uncertainty. In this paper we discuss expanding the modeling paradigm to incorporate uncertain events naturally and concisely in a stochastic programming framework, and demonstrate how Xpress-SP – a stochastic programming suite – can be used for modeling, solving and analyzing problems occurring in supply chain management.

1

Under review for "Supply Chain Optimization", Editors: Joseph Geunes and Panos Pardalos.

1 Introduction A supply chain manager constantly faces the task of making numerous decisions such as amount of raw material to purchase, routing and shipping finished products to distribution centers, inventory control issues, etc. On top of this, the variability in the underlying uncertain components in the supply chain - be it sudden increase in demand, delay in arrival of shipments or an unusual cut in the supply - can make his job difficult. Stochastic programming techniques [1] are most suitable for supply chain systems because they address the issues of optimal decision-making under uncertainty and prepare the manager by hedging against future risks. However, traditional mathematical programming tools available in the market are not suitable to model and analyze such systems because they either lack appropriate functionalities or their modeling complexity renders them impractical to be used for problems occurring in the enterprise (see [2] and [3]). In the following sections we demonstrate how Xpress-SP can be used for modeling, solving and analyzing supply chain optimization problems in an easy-to-use fashion. We begin by characterizing the uncertainties in supply chain processes in section 2. Here we identify various risks an organization is exposed to, their impact on revenue, customer satisfaction and various other attributes that indicate the organization’s performance. This is followed by a discussion on the benefits of using stochastic programming methodologies for efficiently managing supply chains. In Section 3, we discuss the basic concepts of stochastic linear programs. We present general formulations of the 2-stage and multi-stage stochastic programs. Next we discuss the generation of scenario trees by discretization of random variables, which is followed by a description on forming an extensive deterministic equivalent formulation of stochastic problems. Section 4 illustrates the framework of the Xpress-SP suite. We describe the architecture of the Xpress Stochastic Programming (SP) component and its integration with other components of Xpress-MP. We then highlight several tools and functions available in Xpress-SP which facilitate rapid modeling and analysis of stochastic programs. We then consider two examples from the supply chain sector and demonstrate how one can build concise and easy-to-understand stochastic models in Xpress-SP. These models are inspired from the assemble-to-order systems and option contracts in supply chains. Section 5 describes a simple base model for a multi-component multi-product assemble-to-order system where demands are random. We discuss the effect of the number of scenarios on the problem, then compare a myopic policy with the optimal policy, and finally study how scenario manipulation affects the accuracy of the solution. The second example is discussed in Section 6. In this example, we demonstrate how models with correlated random variables can be built in a natural fashion in XpressSP. We also show how to create more complicated asymmetric scenario trees and write stochastic models with global constraints.

2 Uncertainty and its impact on supply chain In today’s economy, organizations are working harder to reduce development timelines, production costs and lead times, and improve quality. With increasing globalization and ever-growing competition, companies are moving towards achieving 1

better control of their supply chains by implementing better decision support systems, and developing superior business processes. There has also been a lot of emphasis on the free flow of information, transparency, and improving visibility within and across organizations; however companies continue to face stock-outs and mark-downs in their supply chain. A clear cause of these upsets can be attributed to the underlying uncertainties and the risks associated with them [5]. Furthermore, the complexity and dependency among various organizational units makes the problem more difficult to handle. With increasing globalization, organization’s exposure to risk is multiplied. At the top-most tier, any enterprise faces essentially three kinds of risks: 1. Financial risk – e.g. excess inventory costs, lost sales 2. Chaos risk – e.g. fluctuations in demand, supply and availability 3. Market risk – e.g. missing on opportunity The impact of financial risks may be both short-term and long-term. It dramatically changes the allocation of resources for production of goods and services, and jeopardizes the organizations’ credibility. The volatility of supply and demand interferes with the smooth operation of the organization. Situations such as breakdowns, canceled orders and late deliveries can significantly affect the dynamics of the supply chain. Some extreme scenarios such as natural calamity, political instability and regulations may severely disrupt the supply chain network. Last but not least, such uncertainties and their consequences often lead to nervousness, overreaction and mistrust. A conservative approach to meeting these risks might drastically increase the overhead, such as amount of resources, man-power, inventory, and lead to a failure to capitalize on opportunities. Other methodologies may not prepare organizations to hedge against the vagaries of the future sufficiently, because they may be subjective or time consuming. Stochastic programming techniques are efficient and objective methodologies for decision making under uncertainty, and provide an overall optimal solution by balancing risks vs. rewards appropriately [6]. Therefore, there is a clear need and opportunity for a shift in paradigm to stochastic optimization tools for structured and superior decision-making.

3 Stochastic Programming basics Stochastic programming problems essentially involve sequential decision making in stages, accompanied by random events occurring between consecutive stages (see [1] and [4]). Such problems occur in supply chains, finance sector, energy power systems, transportation industry etc [7]. The challenge in SP problems is to find decisions at each stage that are overall best for all possible realizations of events occurring after that stage. These problems can be divided into 2-stage and multi-stage problems. From a mathematical programming perspective, in a 2-stage problem, the initial decisions are taken first. These are then followed by a random event. Next, the recourse decisions, which are based on this random event, are taken. The multi-stage problem, as the name suggests, consists of multiple stages, with random events occurring between consecutive stages. As an example, retail managers face periodic uncertainty in availability of raw materials and demand of products, however before these uncertainties are realized, they need to decide on the production capacity for next stages in advance. The recourse action in this context could be for example, a change in production capacity, addition of work-

2

force, or the amount of demand outsourced. In the following sections we discuss the 2stage and multi-stage problems, random events and the associated scenario tree, and the node-based and scenario-based extensive form of the underlying deterministic formulation of stochastic programs.

3.1 2-stage stochastic problems In a 2-stage problem, the initial or the first stage decisions (e.g., system design decisions) are made which are followed by random events such as demand, availability, price, or a combination of these. Then the second stage decisions (e.g. operational decisions) are made. The following figure (Figure 1) illustrates a 2-stage problem:

Stages:

1

2 ξ2

Random Event: Decisions:

Initial

Recourse

Figure 1: 2-stage problem

In the standard form, the 2-stage stochastic program is:

minimize c1′ x1 + E 2 [c~2′ (ξ 2 ) x 2 (ξ 2 )] s.t A11 x1 = b1 ~ ~ ~ A21 (ξ 2 ).x1 + A22 (ξ 2 ).x 2 (ξ 2 ) = b2 (ξ 2 ) l1 ≤ x1 ≤ u1 ~ l2 (ξ 2 ) ≤ x 2 (ξ 2 ) ≤ u~2 (ξ 2 )

∀ξ 2 ∈ Ξ 2 ∀ξ 2 ∈ Ξ 2

where x1 and x2 are the first and the second stage stochastic decision variables respectively. E2[] is the expectation operator with respect to the random event ξ 2 . Ξ 2 represents the state space (the set of possible outcomes or the values that ξ 2 can assume) in the recourse stage. There may be separate values for the objective coefficients c~2′ (ξ 2 ) , ~ ~ ~ right hand side b2 (ξ 2 ) , and matrix coefficients A21 (ξ 2 ) and A22 (ξ 2 ) for each outcome ξ 2 in Ξ 2 , and the recourse decisions x2 (ξ 2 ) depend on ξ 2 , i.e., there are separate sets of recourse decisions for each outcome ξ 2 in the second stage.

3.2 Multi stage stochastic problems Multi-stage problems can be viewed as follows (see Figure 2):

3

2

1

Stages:

ξ2

Random Event: Decisions:

T-1

ξ3

x1

x2

T

ξT xT-1

xT

Figure 2: Multi-stage problem

Formally, the multi-stage stochastic program is defined as follows: minimize c~1′x1 + E 2 [c~2′ x 2 + E3 [c~3′x3 + E 4 [...... + ET [c~T′ xT ]...]]] s.t t′

~

∑A t =1

t 't

~ xt = bt '

∀t ′ ∈ {1,.., T }

~ lt ≤ xt ≤ u~t

where

∀t ∈ {1,.., T }

xt ≡ xt (ξ 2 , ξ 3 ,.., ξ t ) c~t′ ≡ c~t′(ξ 2 , ξ 3 ,.., ξ t ) ~ ~ bt ' ≡ bt ' (ξ 2 , ξ 3 ,.., ξ t ′ ) ~ ~ At 't ≡ At 't (ξ 2 , ξ 3 ,.., ξ t ′ ) ~ ~ lt ≡ lt (ξ 2 , ξ 3 ,.., ξ t ) u~ ≡ u~ (ξ , ξ ,.., ξ ) t

2

3

t

Et [.] ≡ Eξt (ξ 2 ,..,ξt −1 ) [.]

∀t ∈ {1,.., T } ∀t ∈ {1,.., T } ∀t ′ ∈ {1,.., T } ∀t ∈ {1,.., t ′}, t ′ ∈ {1,.., T } ∀t ∈ {1,.., T } ∀t ∈ {1,.., T } ∀t ∈ {2,.., T }

Each of the above entities depends on the sequence of events (ξ 2 , ξ 3 ,..) 2

3.3 Scenario generation If each of the ξt assumes discrete values with certain probabilities, then the

occurrence of possible outcomes at each stage may be represented as a ‘Scenario tree’. An example of a scenario tree with T (number of stages) =3 and S (number of scenarios) =4 is shown in Figure 3.

2

Note that c1, A11, b1, l1, and u1 are not random.

4

(3,1)

P1=p21.p31

(3,2)

P2=p22.p32

(3,3)

P3=p22.p33

ξ31,p31 (2,1)

ξ21,p21 ξ22,p22

(1,1)

ξ32,p32

(2,2)

ξ33,p33

ξ23,p23

(2,3)

ξ34,p34 (3,4)

N1=1

N2=3

P4=p23.p34

N3=4

Figure 3: 3-stage scenario tree

In the tth stage there are Nt nodes. For each stage t in 2 to T, each ξt has Nt outcomes (ξ t1w. p pt ,1 , ξ t 2 w. p pt , 2 ,..,ξ tNt w. p pt , Nt ) 3, where ptn is the conditional

probability of visiting the nth node in the tth stage from its parent node in the t-1th stage. The realizations of ξ2, ξ3,…,ξT correspond to scenarios (paths in the tree). For each stage t and each node n in that stage, the node has an unconditional probability Ptn of being visited, which is equal to the product of conditional probabilities along the path to that node. Similarly, each scenario s has a scenario probability Ps that is equal to the product of conditional probabilities along the path to that scenario. The following observations can be made about the scenario tree:

1.



p t +1,n ' = 1 n ':Node (t +1, n′)∈Children( Node (t , n ))

2. Ptn = 3.

(t ,n )

∏p

tn ( t ′, n′ ):Node ( t ′, n′ ) ∈ path to Node(t,n)

∀n ∈ {1,.., N t }, t ∈ {1,.., T − 1} ∀n ∈ {1,.., N t }, t ∈ {2,.., T }

Nt

∑ Ptn = 1

∀t ∈ {2,..,T }

n =1

4. Ps =



p tn (t , n ):Node ( t , n ) ∈ path to scenario s

∀s ∈ {1,.., S}

S

5.

∑ Ps = 1 s =1

3

w.p stands for ‘with probability’

5

3.4 Underlying deterministic model If we ignored the randomness of the data momentarily, then an underlying deterministic model can be written as follows: minimize

T

∑ c~ ′x t =1

t

t

s.t t′

~

∑A t =1

t 't

~ xt = bt '

∀t ′ ∈ {1,.., T }

~ lt ≤ xt ≤ u~t

∀t ∈ {1,.., T }

3.5 Parsing the underlying deterministic model ~ ~ ~ Given the dependency of the coefficients ( c~t , Att ' , bt , lt , u~t ) of a stochastic program on the random events (ξt), it can automatically be parsed into an extensive form (deterministic equivalent problem) by introducing new variables and constraints. There are basically two ways of creating new variables and constraints: node based and scenario based.

3.5.1 Node based Given a scenario tree, the underlying deterministic model can be parsed into an extensive mathematical program based on the nodes. The basic idea is to add a subscript of a node number to each of the stochastic decision variables (xt becomes xt,n for n=1..Nt). Then the resulting extensive deterministic model would be:

minimize

T

Nt

∑∑ P c′ x t =1 n =1

tn tn

tn

s.t ( t ′ , n′ )

∑A

x

t ′tn′ tn ( t , n ): Node ( t , n )∈Path to Node( t ′, n′ )

ltn ≤ xtn ≤ u tn

= bt 'n′

∀n′ ∈ {1,.., N t ′ }, t ′ ∈ {1,.., T }

∀n ∈ {1,.., N t }, t ∈ {1,.., T }

~ ~ ~ In this model c tn , Att 'n , btn , ltn , utn are the resolved values of c~t , Att ' , bt , lt , u~t at the node( t, n ). 3.5.2 Scenario based A stochastic model can also be parsed based on scenarios. Here each variable is also subscripted by scenarios (xt becomes xt,s for s=1..S). The parsed mathematical program would look as follows:

6

T

S

minimize

∑ P ∑ c′ x s =1

s

t =1

ts

ts

s.t t′

∑A t =1

t 'ts

xts = bt 's

lts ≤ xts ≤ u ts Here cts , At 'ts , bt 's , lts , u ts scenario s.

∀s ∈ {1,.., S }, t ′ ∈ {1,.., T } ∀s ∈ {1,.., S }, t ∈ {1,.., T }

~ ~ ~ are realizations of c~t , At 't , bt ' , lt , u~t respectively in

3.5.2.1 Non-anticipative constraints (NAC) Consider the node(2,2) in Figure 3. When the model is parsed according to scenarios, although we have two separate variables x22 and x23 corresponding to scenarios 2 and 3 at this node, both of them should assume same value since they cannot depend on the future events ( xt ≡ xt (ξ 2 ,..,ξt ) ). Therefore, the following set of non-anticipative constraints also needs to be included in the above formulation: xts = xts′ ∀n ∈ {1,.., N t }, t ∈ {1,.., T − 1}, s ≠ s ′ ∈ Λ tn , where Λ tn is the set of scenarios passing through the node(t,n).

4 Framework of Xpress-SP 4.1 Scope Xpress-SP is used for modeling, solving and analyzing 2-stage and multi-stage stochastic linear problems. The design is primarily focused on ease of modeling and analyzing stochastic problems. Users may create scenario trees in one of the following ways: i. Exhaustively– by specifying the independent or joint discretized distribution of random variables ii. Symmetrically– by specifying the structure of the tree, and discretized distribution iii. Explicitly– by specifying the tree structure and assumed values of random variables in the scenario tree Xpress-SP supports any model of the forms discussed earlier in Section 3.2. Specifically, any of the matrix coefficients, cost coefficients, right hand sides or bounds can be a random variable or a linear/non-linear expression of one or more random variables. Xpress-SP version 1.00 supports Xpress-Optimizer’s primal simplex, dual simplex and barrier algorithms for solving the extensive form of the underlying stochastic linear problems. The branch and bound algorithm in Xpress-Optimizer is used for solving the extensive forms that are MILPs. One may also solve related problems such as the expected value problem and the perfect information problem (see Sections 5.3.2 and 6.5.1.1).

7

4.2 Architecture Xpress-SP is built using Mosel’s Native Interface technology [8]. At the modeling level various new ‘types’, and ‘functions’ and ‘procedures’ based on these ‘types’ are defined in the module ‘mmsp’. The library supports several ‘control parameters’ for controlling the behavior of Xpress-SP at the scenario generation, modeling, and solution analysis phases. This library is further integrated with Xpress-Optimizer for solving the problem and with Xpress-IVE for visualization and analysis. Figure 4 gives a pictorial view of the architecture of the Xpress stochastic programming suite.

Mosel

Types

Xpress IVE

Functions & Procedures

Xpress Optimizer

Control parameters

Figure 4: Architecture of Xpress-SP

Mosel supports structures such as ‘sets’ and ‘arrays’, programming constructs such as ‘forall’ and ‘while’ loops, and other logic building functions. These tools together with the Native Interface technology have facilitated the evolution of Xpress-SP’s semantics as a natural extension of modeling conventions. The equivalent extensive form of the stochastic problem is solved using Xpress-Optimizer which is one of the best solvers available in the market for solving large scale LP, MILP, QP and MIQP. The structure of the stochastic problem in the ‘mmsp’ module is kept simple and easy-to-use by functionally interfacing it with the Xpress Optimizer library. Xpress-IVE is a state-ofthe-art Intergrated Visual Environment which brings together the Xpress products and facilitates rapid model prototyping and analysis. It is integrated with Xpress-SP and provides visualization of stochastic models, scenario trees, and stochastic solutions.

8

4.2.1 ‘mmsp’ types The following types –which essentially act as objects for stochastic programs –are defined in ‘mmsp’: • sprand: Random variable that assumes different values with certain probabilities, e.g., demand. • spvar: Stochastic decision variable that assumes values in different scenarios or at different nodes in the scenario tree. • splinctr: Stochastic constraint built with ‘reals’, ‘sprands’, and ‘spvars’. • sprandexp: An expression built with one or more ‘sprands’ and/or ‘reals’. 4.2.2 Functions and Control parameters Xpress-SP provides various functions and control parameters for easy scenario generation and manipulation, rapid modeling of the problem, and for solution analysis. Functions are also provided for evaluating stochastic entities at nodes in the scenario tree or in scenarios. Functions and procedures for accessing Xpress-Optimizer controls are also defined.

4.3 Modeling interface One can easily write 2-stage and multi-stage stochastic linear models in the ‘mmsp’ module. The syntax of the language is similar to Mosel’s modeling language for linear programs. Xpress-IVE provides a modeling interface as shown in Figure 5.

Figure 5: Xpress-SP model – modeling interface

9

4.4 Scenario generation and manipulation Xpress-IVE provides a ‘pie view’ and a ‘block view’ for the visualization of the scenario tree. In the block view the height of the block is proportional to the conditional probability of the node in the scenario tree. The following screen shot (Figure 6) shows a scenario tree corresponding to sprands belonging to the second and third stage with distributions {2 w.p 0.6, 8 w.p 0.4} and {3 w.p 0.3, 5 w.p 0.6, 7 w.p 0.1} respectively. 3 w.p .3 2 w.p .6

5 w.p .6 7 w.p .1

8 w.p .4

Figure 6: Scenario tree visualized in IVE

Similarly, tools are also provided for creating and visualizing asymmetric trees. The following figure (Figure 7) shows a scenario tree with three nodes in the second stage. The first node in the second stage has two branches, whereas other nodes in the second stage have one each.

Figure 7: Asymmetric scenario tree

10

One may also manipulate the scenario tree after the generation of scenarios in IVE itself. IVE provides scenario aggregation and deletion tools and updates the scenario tree dynamically as shown in Figure 8.

Figure 8: Scenario tree: before and after aggregation

4.5 Visualization and analysis IVE also enables visualization and analysis of stochastic entities, their distributions, the optimal solution, the parsed matrix, and the scenario tree. The following figure (Figure 9) gives a pictorial view of these tools.

11

Figure 9: Visualization tools in Xpress-SP

IVE can easily handle scenario trees with thousands of scenarios. The Hyper version of Xpress optimizer can handle and solve large scale problems. This makes Xpress-SP a very robust and scalable tool for stochastic programming. In the next sections we demonstrate the functionalities available in Xpress-SP by illustrating the modeling and analysis of two applications in supply chain management.

12

5 SCM application1: 2-stage Assemble to order (ATO) system In this section we consider an example from assemble to order systems, and demonstrate how it can be modeled as a 2-stage stochastic linear program and analyzed in Xpress-SP.

5.1 Problem and applications In order to manage their inventory efficiently, more companies are moving toward assemble to order systems [9], where typically a set of components are stored in inventory and one or more components are assembled together to produce a range of products. ATO systems involve various challenges such as balancing supply and demand through pricing contracts, dynamically sequencing components, maintaining inventory levels across components with varying lead times, etc. However, their popularity is growing rapidly in various manufacturing sectors because they provide several benefits such as quick response time to order fulfillment, low delivery costs, and high level of product variety. Some of well-know implementations of ATO systems can be seen in companies such as Dell, HP, BMW, GE etc [10]. 5.1.1 Problem description We study a simple yet well-known ATO system which is comprised of a set of components and products as described in [11]. Each product is manufactured by assembling a subset of available components. This can be visualized as shown in Figure 10.

Components

Assembly

Products

Figure 10: Assemble to order systems

The demand of products is random, and the inventory level of the components must be such that the expected total cost is minimized. The total cost consists of inventory holding costs and penalties for lost sales of products.

13

5.1.2 Mathematical formulation Model parameters: m: total number of components (indexed by i ) n: total number of products (indexed by j ) Aij: number of units of component i required to make one unit of product j x0: vector of initial inventory of components c: vector of unit cost of procurement of components h: vector of unit cost of components p: vector of unit costs for shortage of products

Uncertainty: ~ d j : random demand for product j Variables: y: vector of inventory position of components z: vector of amount of product produced from the components x: vector of excess of components left in the inventory after the demands are met w: vector of lost sales of products Model:

~ minimize c( y − x0 ) + E d~ ⎧⎨ min hx + pw : Az + x = y, z + w = d ⎫⎬ y ≥ x0 ⎩ x , z ,w≥0 ⎭

5.2 Stochastic framework In the stochastic programming context, the problem can be visualized as follows (Figure 11):

1

y

2

~ d

x, z, w

Figure 11: sequential event schematics

At the first stage, the initial decision y - to position the inventory of components is taken, which is followed by a random event corresponding to the realization of demand at the second stage. Then the state variables x, z and w are determined.

14

5.3 SP model In this section we highlight the key elements of the Mosel stochastic model for the problem. The complete model is shown in Appendix 1.1. We also compare it with its deterministic equivalent formulation in Mosel. Given m components and n products, first the stochastic entities are declared.

Demand - being a random variable - is declared as ‘sprand’ for each product. Stochastic decision variables are declared as ‘spvar’. The objective function and other stochastic constraints are declared as ‘splinctr’. This is followed by setting the stages and associating each ‘sprand’ and ‘spvar’ to a stage as follows:

Next, the scenarios are generated by reading in the discretized values and probabilities (not shown here), followed by setting the distributions of demands. Then an exhaustive scenario tree is generated based on these distributions.

Finally, the model constraints are written, followed by a call to the optimization routine (declarations for c, h and p not shown here).

15

The model formulation for stochastic programming problems in Xpress-SP is natural. It is parsed internally into its deterministic equivalent (extensive form). Figure 12 highlights the key differences between a stochastic model written using Xpress-SP, and its extensive form written using Mosel4.

Figure 12: Difference between SP-model and its extensive form

5.3.1 Analysis of the problem. The special case of ATO systems with one component and one product is indeed the well known news vendor’s problem. In the following sections we compare the results obtained for this problem with the theoretical optimal results for the news vendor’s problem. Since the actual distributions need to be discretized, we first study the loss in accuracy with respect to discretization of distributions. We also analyze the gains from using stochastic programming as opposed to a methodology where one would solve the deterministic problem based on expected demands.

5.3.1.1

The news vendor’s problem The problem discussed in Section 5.1.2 is the generalized case of the news vendor’s problem. Specifically, substituting m=n=1 and A11=1, we obtain the news vendor’s problems with cost c, reward p and salvage value –h. In this section, we discuss ~ this problem with p= 100, h= -20, c= 50, and d uniformly distributed between a and b, where a=50 and b=150, and the optimal inventory is given by

⎛ p−c⎞ ⎟⎟ + a = 112.5 . y * = (b − a ).⎜⎜ ⎝ p+h⎠ 4

Only relevant part of the code is shown

16

Let us first consider the effect of discretization on the optimal results obtained. We divide the interval (a, b) into S equal parts and then solve this problem as a 2-stage stochastic linear problem with S scenarios. The following figure (Figure 13) shows the IVE-plot of optimal inventory in a 2-stage stochastic problem with S scenarios (see Appendix 1.2 for the Mosel code for generating S scenarios).

Figure 13: IVE plot of optimal inventory with respect to number of scenarios

From the above figure it is clear that as the number of scenario increases, the optimal inventory tends towards actual optimal solution (112.5). However, the problem size and hence the time required to solve the problem also keeps on increasing rapidly. 5.3.2 Comparison with myopic (greedy) approaches Now consider the original problem with the following parameters: • m= 3; n= 5 • c1,..,c3= 5; h1,..,h3= 1; p1,..,p5= 20 • A =[1, 0, 1, 0, 0; 1, 0, 0, 3, 2; 1, 3, 2, 1, 0] ~ ~ • d1 ,.., d 5 = {5 w.p 0.2, 10 w.p 0.6, 15 w.p 0.2} This 2-stage problem with S=243 (35) scenarios has the optimal solution y*= [20, 40, 53.33]. From the distribution of optimal solution of w2 (see Figure 14) we see that the probability of sales of product 2 being lost is .712 (1-.288).

17

Figure 14: IVE plot of probability distribution of lost sales of product 2

Now, consider a myopic policy in which the inventory level is decided by considering only the expected demand (10 units) for each product and the objective is to minimize the penalty cost of not meeting the demand. Then the optimal solution is y= [20, 60, 70]. Clearly, the increase in inventory would cause a significant change in the total inventory cost in the second stage. This can be observed in Figure 15 which shows that the Pr{Total inventory cost > 10} is 0.4624 as opposed to 0.09288 in the optimal solution.

Figure 15: Probability distribution of Total inventory cost

5.3.3 Effects of scenario manipulation One of the key aspects in an effective SP practice is the generation of scenarios that closely represent the true underlying distribution of random entities, while keeping a reasonably low number of scenarios, so that the problem size is manageable. One may also apply scenario manipulation strategies, e.g., deletion or aggregation of ‘extreme’ (high/low demand) scenarios. In the following section, we demonstrate how one may aggregate scenarios and further analyze the problem in Xpress-SP.

5.3.3.1 Aggregation based on total demand For the problem with parameters given in Section 5.3.2, one of the criteria for aggregating the scenarios could be total demand, i.e., all scenarios that have same total demand of products would be aggregated together. Using this strategy we obtain 11 scenarios (corresponding to total demands of 25, 30, ... , 75). The optimal solution for this reduced problem is y= [18, 39, 58]. The total cost is 2.6% lower than the optimal cost obtained under exhaustive scenario tree. However, in order to evaluate the effect of aggregation, we should test this solution in the original problem, by fixing the y variables and solving the problem. The aggregation can be done in Mosel as follows:

18

In this code AggScens() is a user-defined procedure for aggregating the scenarios. This procedure is shown in Appendix 1.3. The ‘mmsp’ procedure spfix() is used for fixing variables at particular values. This is followed by calling the procedure spgenexhtree() to regenerate the original tree. Now the new stochastic problem is solved again by fixing the y variables at the optimal solution obtained from the reduced problem. It is observed that the objective function value is 0.65% higher than the optimal cost obtained from the original stochastic problem. Considering the reduction of the number of scenarios from 243 to 11, it can be safely concluded that this scenario aggregation strategy is reasonably good. Note that because of the independent and symmetric discretized distributions of demands, the strategy works well for this instance of the problem.

6 SCM application 2: Option contract in supply chains Contracts are used by suppliers and buyers to protect themselves against the volatility of demand and market competition. Contracts typically commit involved parties to a pre-defined price or quantity of the underlying commodities. Additionally, they may provide various options such as an option of returning a certain percentage of the unsold items, a provision of securing a pre-determined amount of raw material, etc. From the suppliers’ perspective, contracts assure customers and help in consolidating revenues. The format and nature of the contracts in supply chains varies radically across segments of the industry, and the terms and conditions of these contracts also depend on the supplier and the buyer. Both the buyer’s and the supplier’s problem can be modeled in a multi-stage stochastic framework to achieve new managerial insights and obtain better channels of distribution in the supply chain. The following example is inspired by the work of van Delft and Vial [12] in modeling an option contract in supply chain as stochastic program in AMPL. In the following sections we demonstrate how to model and solve this problem using Xpress-SP.

6.1 Problem description We consider the problem of a buyer who is engaged with a supplier in a contract having periodical commitment with options, for a given number of stages. At the beginning of the horizon, both the parties agree to a fixed amount of product that would be delivered at each stage to the buyer at a specified price. The supplier has a limited amount of options available for each stage, with each unit of an option giving the buyer a right to purchase a unit of product. Whenever this option is exercised, the product is delivered at the next stage. Initially, the buyer may also buy these options for each of the

19

stages at a specified price. At each stage, the buyer creates finished goods from the total amount of product available, and sells them in the market. The demand of finished goods at each stage is uncertain. Hence, at each stage and at a specified exercise price, the buyer may buy additional product (by exercising one or more of the options bought for that stage), in order to meet the demands in the following stages. The unmet demand in each stage is penalized and carried over to the next stage, whereas excess quantity is stored in an inventory. If there is excess inventory of products left at the end of the horizon, they are sold at a salvage value, otherwise the unmet demand is lost.

6.2 Mathematical model Decision variables: Qt: Fixed order of products decided at stage 1, and delivered at stage t∈{2,..,T} Mt: Number of options bought at stage 1, which may be exercised at stage t ∈ {2,..,T-1} mt: Number of options exercised at stage t, and delivered at stage t+1, for all t ∈ {2,..,T-1} State variables: It: Finished goods inventory at stage t∈{2,..,T} It+: Physical finished goods inventory at stage t∈{2,..,T} It-: Backorder of finished goods inventory at stage t∈{2,..,T} Uncertainty: Dt: Demand of finished goods at stage t∈{2,..,T} Data5: ν: Unit salvage value of finished goods (in $) M : Bound on number of options that can be bought at each stage o: Unit price for buying an option (in $) e: Unit price of exercising an already bought option (in $) r: Unit selling price of finished goods (in $) p: Unit purchasing cost of a product from the supplier (in $) s: Unit shortage cost for finished goods (in $) h: Unit holding cost for finished goods (in $) The process for a problem with T=3 stages can be visualized as follows (Figure 16):

5

We assume data is constant across the stages, however this assumption can easily be relaxed

20

Fixed

D2

1

D3

Q2

2

Q3

Options Exercised

m2

Demand

3=T

Figure 16: Event schematics

In the above figure, the tails of the arcs indicate the stage at which decisions are taken and the head indicates the stage when they come into effect. The inventory level across stages is shown in Figure 17.

m2 D3

Inventory I3 + Q2

-I2-

D2 Q3

1

2 Stages

3=T

Figure 17: Inventory position at each stage

Model formulation: The revenue and expenditure functions are defined as follows: T ~ ~ R( I + , I − ) = r ( D2 − I 2− ) + ∑ r ( Dt + I t−−1 − I t− ) + vI T+ t =3

T −1

T

t =1

t =1

Ε( I + , I − , m, Q, M ) = ∑ (emt + oM t ) + ∑ (hI t+ + sI t− + pQt )

21

maximize R ( I + , I − ) − Ε( I + , I − , m, Q, M ) s.t ∀t ∈ {2,.., T } I t = I t+ − I t− ~ ⎧⎪Qt − Dt if t = 2 It = ⎨ ~ ⎪⎩ I t −1 + Qt + mt −1 − Dt ∀t ∈ {3,.., T } 0 ≤ mt ≤ M t ≤ M ∀t ∈ {2,.., T − 1} Qt , I t+ , I t− ≥ 0

∀t ∈ {2,.., T }

6.3 Demand process It is assumed that the demand at a stage is correlated with the demand in its previous stage, therefore they: • form a conditionally heteroskedastic Gaussian process implying: ~ ~ 1. E ( Dt +1 Dt = d t ) = µ + ρ (d t − µ ) ~ ~ 2. Var ( Dt +1 Dt = d t ) = σ 2 (1 − ρ 2 ) ~ where µ and σ 2 are the unconditional mean and the variance of Dt respectively, ~ ~ and ρ is the correlation coefficient between Dt and Dt +1 6 • are normally distributed, and therefore

⎧⎪µ + ρ (d − µ ) + ε~ ~ ~ σ 2 (1 − ρ 2 ) ∀t ∈ {2,.., T − 1} t t + 1 E ( Dt +1 Dt = d t ) = ⎨ ⎪⎩µ + ε~t +1σ t =1 ~ where ε t is Normally distributed with mean 0 and variance 1 ∀t ∈ {2,.., T } 6.3.1 Discretization 2 If ε~ is normally distributed with mean µ ε and variance σ ε (in the problem under

consideration µ ε =0 and σ ε =1), then it is discretized into N ε points by dividing the interval ( µ ε +3 σ ε , µ ε -3 σ ε ) into N ε equal sub-intervals, implying 2



length of each sub-interval δ ε = 6 / N ε



the nth discretized value ε n = ( µ ε − 3σ ε ) + (n − 1 / 2)δ ε



the nth discretized probability p n =

6

1 2πσ ε

2

e

1 ⎛ ε −µ − ⎜⎜ n ε 2⎝ σε

⎞ ⎟ ⎟ ⎠

∀n ∈ {1,.., N ε }

2

δε

∀n ∈ {1,.., N ε }

We assume that the mean, variance and correlation coefficient is independent of stage, however this assumption may easily be relaxed

22

6.4 Xpress-SP model In this section we demonstrate the stochastic program in Xpress-SP. For clarity, all the data values are explicitly shown in the model itself, however one can easily separate the data and the model. Here we consider the case with7 T=3, r=12, ν=2, o=1.5, e=8, p=8, s=6, h=0.5, M =10000, µ =1500, σ =330, ρ =0.5. Also, we assume that N ε 2 = 41 and N ε 3 = 31 , which generates a scenario tree with 1, 41, and 1271 (41x31) nodes in the first, second and the third stage of the scenario tree respectively. SCM.mos

7

This data is assumed by van Delft and Vial

23

24

The model begins with declaring stages and other entities, which is followed by the setting of stages. When the parameter xsp_implicit_stage is set to true, all the stochastic entities are implicitly associated with one of the stages under the assumption that the last set for indexing the arrays in which they are stored is the stage set, however one can override this assumption by setting their stage explicitly. Demands are defined as ‘sprandexp’, and are declaratively assigned their dependence on other ‘sprands’ and ‘sprandexps’ in the forall loop, which is followed by scenario generation. In this model, the procedure GenScenTree() is defined for creating the scenario tree. It calls the procedure GetNormDist(), gets the discretized distribution as discussed in Section 6.3.1, and sets the distribution by calling the ‘mmsp’ procedure spsetdist(). Next, the stages and types of other ‘spvars’ are defined, the model is formulated and then optimized.

6.5 Analysis of stochastic solution The IVE stochastic dashboard displays the model information (see Figure 18). There are 3 stages, 1271 scenarios corresponding to each node in the last stage, 2 random variables, 10 stochastic decision variables, and 6 stochastic constraints. Each of these entities is prefixed by a curly bracket which states its stage number.

Figure 18: Model information

The model is parsed internally by creating new variables corresponding to the nodes at the stage of the decision variable in the scenario tree (see Section 3.5.2). The matrix thus generated is ordered according to stages, and within each stage, according to

25

the nodes in that stage. For this problem the Xpress-Optimizer displays the following statistics: Problem Statistics 2666 ( 399 spare) rows 3980 ( 0 spare) structural columns 9185 ( 1377 spare) non-zero elements

The extensive form of matrix can be visualized in IVE (see Figure 19). Note that each stochastic decision variable or constraint is further suffixed by a curly bracket which states the variable’s or constraint’s node number in the scenario tree.

Figure 19: Node based matrix

As mentioned in Section 3.5.2, any stochastic model can also be parsed according to scenarios. This is achieved in Xpress-SP by setting the parameter xsp_scen_based to true. The scenario-based problem has the following statistics: Problem Statistics 16356 ( 2453 spare) rows 12710 ( 0 spare) structural columns 36525 ( 5478 spare) non-zero elements

The matrix structure looks as follows:

26

Figure 20: Scenario based matrix

In the extensive form obtained from the scenario based parsing, each stochastic decision variable or constraint is indexed by scenarios. In Figure 20, the variables and constraints are suffixed by curly brackets indicating their scenario numbers. Note that the constraints are ordered based on scenarios, so they appear in the block diagonal form. They are followed by the non-anticipative constraints (see Section 3.5.2.1). 6.5.1 Comparison with a related problem If we order the optimal net profits in various scenarios increasingly and then plot them against cumulative probabilities of corresponding scenarios (this is done automatically in IVE, see Figure 18), it is observed that there could occur a loss of as high as $12,658.36 and a maximum profit of $12,655.8. The maximum expected profit is $8360.43 with the probability of loss less than 0.0843. The optimal number of options bought initially for stage 2 is 468 and the fixed orders for stage 2 and 3 are 1982 and 910 units of product respectively.

6.5.1.1 Perfect Information problem In this section we analyze the problem in the Perfect Information context. Assuming that the future is known with certainty, we solve the problems for each scenario independently. Such problems can be solved in Xpress-SP by calling maximize(P,”PI.”) where, “PI” refers to the perfect information problem. Each scenario would have its own optimal solution for Q and M. We can aggregate these solutions based on scenario probabilities and obtain a unique implementable solution. The aggregated solution turns out to be M=0 and Q=[1500, 1500] for this problem. Next, we compare this solution with the optimal solution of the original recourse stochastic problem by fixing the first stage variables at the aggregated values obtained, and solving the problem in the stochastic framework. This can be done in Xpress-SP by passing the 27

string “PIr.” to maximize(). It is observed that the maximum profit for this problem is $923.93 less than the optimal profit8; implying a gain of about 11.05% by using stochastic programming for decision-making.

6.6 Reduced scenario tree

van Delft and Vial [12] studied the effect of discretization of ε~2 and ε~3 on this problem with the number of discretization ranging from 5 to 321. Such an analysis for this problem can easily be done in Xpress-SP by dynamically reading N ε 2 and N ε 3 in the model shown in Section 6.4. Next, we focus on building asymmetric scenario trees in Xpress-SP. Although SP provides great insights into the dynamics of a problem with respect to uncertainty and constructing probability distributions of various stochastic entities, it becomes increasingly challenging from a computational point of view to solve stochastic problems as the number of scenarios increases. Hence, in order to prevent the size of the problem from growing too fast, it is important to keep the number of scenarios small, while maintaining the distributions as close to reality as possible. One of the key strategies for restricting the size of the scenario tree is to reduce the number of branches emerging from each node in the later stages. In a sequential decision making process the later decisions depend highly on the initial ones; therefore, it is important to have more realizations for the initial decisions than the later ones. Furthermore, if the probability of visiting a node in a given stage is much smaller as compared to other nodes in that stage, one may curtail the number of branches emerging from that node because the detailed future information collected on that node by having many branches will neither be fruitful nor affect the optimality of the solution. For this purpose van Delft and Vial suggested fine and coarse branching strategies and proposed the following scheme for switching from one to another:

⎧ f ⎪Nt ⎪ Brtn = ⎨ ⎪N c ⎪⎩ t

if

Ptn ≥ SwitchLevelt 1/ N t

P if tn < SwitchLevelt 1/ N t

∀n ∈ {1,.., N t }, t ∈ {1,.., T − 1}

where, N t is the number of nodes in the scenario tree at the stage t: t ∈ {1,.., T } Ptn is the unconditional probability of occurrence of nth node at stage: n ∈ {1,.., N t }, t ∈ {1,.., T } Brtn is the number of branches emerging from nth node at stage: n ∈ {1,.., N t }, t ∈ {1,.., T − 1}

tth tth

N t f is the number of branches emerging from a node in tth stage, if branching is fine at

that node: t ∈ {1,.., T − 1}

N tc is the number of branches emerging from a node in tth stage, if branching is coarse at

that node: t ∈ {1,.., T − 1} 8

This difference is often referred to as Expected Value of Perfect Information (EVPI)

28

SwitchLevelt is the switching level defined at each stage for switching from fine

branching to coarse branching: t ∈ {1,.., T − 1}

6.6.1 Implementation in Xpress-SP A scenario tree based on such a rule can be easily created in Xpress-SP. For the problem under consideration, the procedure ‘GenScenTree()’ in the Mosel implementation (see Section 6.4) is changed to take the three arguments: N t f , N tc , and SwitchLevelt., as shown next.

The above procedure defines a boolean dynamic array ‘fine’. By stating it as ‘dynamic’, we ensure that Mosel doesn’t create any unnecessary entry. If ‘finetn’ is true,

29

then the number of branches emerging from the nth node in the tth stage is N t f , otherwise it is N tc . The procedure begins by initializing N 1 and P11 to 1, and then N t , Ptn and Brtn are updated within the ‘forall’ loop. For the purpose of illustration, we set N f = [3,3] , N c = [3,1] 9and SwitchLevel = [0.5,1.5] , which generates the following scenario tree10:

Figure 21: Reduced scenario tree

6.7 Global constraints In this section we demonstrate how global constraints can easily be modeled in Xpress-SP. Global constraints are different from the regular constraints in SP, in the sense that instead of having decision variables along a path to a particular scenario or a node in the scenario tree, these constraints chain variables across all the nodes of a particular stage or all the scenarios (depending on whether the problem is ‘node based’ or ‘scenario based’). Such constraints are particularly useful in writing certain financial or managerial constraints. We show how to model ‘chance constraints’ as global constraints in Xpress-SP. Next, we also present modeling of global constraints in the context of minimizing the conditional value at risk for this problem, as proposed by van Delft and Vial [12]. 6.7.1 Modeling chance constraints Chance constraints are quite common in stochastic programming [1]. Conceptually, one can think of them as the constraints that need to be satisfied only with certain probability. However, not only are they difficult to model in the traditional algebraic modeling languages, the problem becomes very difficult to solve to optimality. In the context of the current problem, consider the distribution of inventory at the last stage (Figure 22).

Xpress-SP also supports problems with trap stage scenario trees, e.g., if N f =[3,3] and N c =[ 3, 0 ] , then the first and the third node in the second stage will not have any children in the generated scenario tree. 10 Here we assume that if N ε = 1 , then ε ={0 w.p 1} 9

30

Figure 22: Inventory position in the last stage

The probability that net inventory at the last stage (IT) goes below 0 is 0.42. Now consider a managerial constraint that stipulates that the Pr{IT0 whenever z=1. The global constraint enforces the chance constraint. Note that this constraint is internally parsed as NT

∑ PTn. z n ≤ β

. Hence, the total probability of a negative IT is enforced to be less than or

n =1

equal to β. The corresponding Mosel implementation is presented next.

31

The extensive form of the problem with chance constraint contains 1271 binary variables. The search strategy for finding a good solution is further enhanced by setting Xpress Optimizer control parameters. Using Xpress Optimizer version 14.24, disabling automatic cut generation during the reduction of relaxed LP, and limiting a maximum of 10000 rounds of Gomory cuts at nodes in the branch and bound tree, a 1% optimal solution with objective value of 8200.5 is obtained after 34 seconds on 2.2 Ghz, P-4 machine with 1 GB RAM. The probability of inventory going below zero is 0.2487. The distribution of inventory at the last stage after implementing the chance constraint on it is shown below:

Figure 23: Last stage inventory distribution

6.7.2 Calculating conditional value at risk The Conditional Value at Risk measure (CVaR) is closely related to the traditionally used Value at Risk measure (VaR) in industry. It is the expected loss under the condition that loss exceeds VaR [13]. Formally, CVaR is defined as: CVaR (α ) = E[ L L ≥ S (α )]

where, L is the loss function α is the risk level: 0 < α < 1 S (α ) is the threshold above which CVaR need to be calculated. This can be visualized as shown in Figure 24.

32

1-α P{L≤ s}

S(α) CVaR(α) s Figure 24: Plot of cumulative probability distribution of loss function

In [13] authors showed that CVaR is a solution to the minimization problem: CVaR(α ) = min{S + E[max(L − S ,0)] / α } S

Hence, in the stochastic programming context, CVaR can be calculated by introducing variables CVaR , and S belonging to stage 1, and a non-negative variable z belonging to stage T. z represents max(L-S,0) therefore a constraint z ≥ L − S must also be introduced. Next, a bound c is introduced on CVaR . During minimization the term θ .CVaR is added to the objective function where θ is sufficiently small, so that it does not perturb the optimal solution to the original problem. The constraint S + z / α ≤ CVaR NT

is added and set as ‘global’ implying S + ∑ PTn z n / α ≤ CVaR n =1

The Mosel implementation is shown below:

33

After solving the problem for 41 nodes in second stage and 1271 nodes in the third, the minimum value of CVaR obtained is 4053.4 with S=2283.66. Figure 25 shows the distribution of the Loss function for Loss greater than S.

Figure 25: Cumulative probability distribution for Loss ≥ Sα

7 Summary In this paper we have demonstrated how problems that occur in supply chains can be modeled, solved and analyzed in a stochastic programming framework using XpressSP. We began by identifying the need and applicability of stochastic programming for efficient supply chain management. Next, we described the basics of stochastic programs including the structure of a scenario tree and the node-based and scenario-based extensive formulation of the multi-stage stochastic linear problem. Then we summarized the capabilities of the Xpress-SP suite by describing its architecture, functionalities and other tools. We then illustrated the utility, flexibility and scalability of Xpress-SP using two examples from supply chains. The first example was taken from assemble to order systems and modeled as a 2-stage stochastic program. There we analyzed the variation of optimal solution with respect to number of scenarios followed by a comparison with a myopic policy and a brief discussion on the effect of scenario aggregation. The second example was based on supply chain contracts where we illustrated the functionalities of Xpress-SP in greater detail. In that example we showed how scenario trees with correlated random variables can be easily generated. We demonstrated how to analyze the problem and solution visually using Xpress-IVE and model chance constrains using global constraints in Xpress-SP.

34

8 Conclusion Problems in supply chain management involve a lot of uncertainties and risks. Stochastic programming techniques are promising methodologies for better decisionmaking under uncertainty, as they provide overall best decisions and balance rewards against risks. Xpress-SP provides a range of tools and functions for developing 2-stage and multi-stage stochastic linear programs. The syntax of the modeling language available in Xpress-SP is natural for problems requiring decision-making under uncertainty. It is concise, flexible and scalable, and its integration with Xpress IVE makes Xpress-SP a state-of -the-art technology for Stochastic Programming.

35

References [1] John R. Birge, Francois Louveaux, “Introduction to Stochastic Programming”, Springer Series in Operations Research, 1997. [2] R. Fourer and D.M. Gay, “Proposals for Stochastic Programming in the AMPL Modeling Language”, Session WE4-G-IN11, International Symposium on Mathematical Programming, Lausanne, August 27, 1997, available at http://iems.nwu.edu/~4er/SLIDES/lsn9708v.pdf. [3] Fragniere E. and J. Gondzio, “Stochastic Programming from Modeling Languages”, Chapter in: H. Gassmann, S. Wallace and W. Ziemba (eds.) Applications of Stochastic Programming, SIAM Series on Optimization, 2002, available at http://www.maths.ed.ac.uk/~gondzio/gondzio/cvgondzio.html. [4] Jitka Dupacova, Jan Hurt and Josef Stephan, “Stochastic Modeling in Economics and Finance”, Vol 75, Kluwer Academic Publishers, 2002. [5] Sunil Chopra and Peter Meindl, “Managing Uncertainty in a Supply Chain: Safety Inventory”, Supply Chain Management; Strategy, Planning, and Operation, PrenticeHall Inc., 2001. [6] Jeremy F. Shapiro, “Decision Trees and Stochastic Programming”, Modeling the Supply Chain, Duxbury- Thomas Learning, 2001. [7] David Morton, “Stochastic Programming Applications”, available at http://www.dashoptimization.com/secure/w_papers.shtml. [8] Yves Colombani and Susanne Heipcke, “Mosel: An Overview”, May 2002, available at http://www.dashoptimization.com/pdf/Mosel1.pdf. [9] Economist. A long march: Mass customization July 2001. Vol. 360, Issue 8230. [10] Bylinsky, G. (2000). Heroes of U.S. manufacturing. Fortune 141,. [11] Jing-Sheng Song, Paul Zipkin, “Supply Chain Operations: Assemble-to-Order Systems”, Forthcoming in Handbooks in Operations Research and Management Science, Vol. XXX: Supply Chain Management, T. de Kok and S. Graves (eds.), North-Holland. [12] Ch. van Delft and J.-Ph.Vial, “A practical implementation of stochastic programming: an application to the evaluation of option contracts in supply chains”, Forthcoming in Automatica, 2003. [13] R.T. Rockafellar and S. Uryasev, “Optimization of conditional value at risk”, Journal of Risk, 2, 21–41, (2000).

36

1 Appendix 1.1 Mosel stochastic model for Assemble to order systems The following model is built assuming: • No initial inventory (x0=0) • Each of the products’ demand is independently distributed with a known discretized distribution ATO.mos _______________________________________________________________________________ model "Assemble to order" !model name uses 'mmsp' !mosel model library for stochastic programming parameters !can be changed dynamically at run time DatFile="ATO.dat" DistFile="ATOdist.dat" end-parameters declarations m,n:integer !dimensions end-declarations initializations from DatFile !read dimensions m n end-initializations declarations Components=1..m !set of components Products=1..n !set of products c,h:array(Components) of real !procurement, holding cost p:array(Products) of real !penalty cost A:array(Components,Products) of real end-declarations initializations from DatFile c h p A end-initializations declarations Stages=1..2 !2-stage stochastic problem d:array(Products) of sprand !random demand x,y:array(Components) of spvar !excess inventory, inventory position w,z:array(Products) of spvar !lost sales, amount produced TotCost:splinctr !total cost incurred SupBal:array(Components) of splinctr !supply balance DemBal:array(Products) of splinctr !demand balance end-declarations !-----------------------------Stage association--------------------------spsetstages(Stages) !set stages forall(i in Components) do spsetstage(y(i),1);spsetstage(x(i),2); end-do forall(j in Products) do spsetstage(d(j),2);spsetstage(w(j),2);spsetstage(z(j),2); end-do !----------------------------Scenario generation------------------------declarations nVals:integer !number of discretized points

37

end-declarations initializations from DistFile nVals end-initializations declarations val,prob:array(1..nVals) of real !discretized values and probabilities end-declarations initializations from DistFile val prob end-initializations forall(j in Products) spsetdist(d(j),val,prob) !set discretized distribution spgenexhtree !generate exhaustive scenario tree !--------------------------Model formulation-----------------------------TotCost:=sum(i in Components) (c(i)*y(i)+h(i)*x(i))+ sum(j in Products) p(j)*w(j) forall(i in Components) SupBal(i):=sum(j in Products) A(i,j)*z(j)+x(i)=y(i) forall(j in Products) DemBal(j):=z(j)+w(j)=d(j) minimize(TotCost) !Optimization end-model

______________________________________________________________________________________

1.2 2-stage S-scenario tree with uniform distribution _______________________________________________________________________ declarations S=200 a=50 b=150 val,prob:array(1..S) of real end-declarations val(1):=a+((b-a)/S)/2 forall(s in 2..S) val(s):=val(s-1)+(b-a)/S forall(s in 1..S) prob(s):=1/S forall(j in Products) spsetdist(d(j),val,prob) spgenexhtree

_______________________________________________________________________

1.3 Aggregation procedure for ATO model _______________________________________________________________________ procedure AggScens declarations TotDem:array(range) of real aggSet:set of integer end-declarations S:=0 forall(s in 1..spgetscencount) do found:=false TotScenDem:=sum(j in Products) speval(d(j),s) if(S>1) then forall(s_ in 1..S) do if(TotScenDem=TotDem(s_)) then found:=true

38

break end-if end-do end-if if(not found) then S+=1 TotDem(S):=TotScenDem end-if end-do forall(s_ in 1..S) do aggSet:={} forall(s in 1..spgetscencount) do TotScenDem:=sum(j in Products) speval(d(j),s) if(TotScenDem=TotDem(s_)) then aggSet+={s} end-if end-do if(getsize(aggSet)>1) then spaggregate(aggSet) end-if end-do end-procedure

_______________________________________________________________________

39