Regulating Traffic Flows under Air Quality Constraints: Two-Stage Stochastic Optimization Application

advertisement
ISEN 689 Fall 2007: Large-Scale Stochastic Optimization
Semester Project Report
Regulating Traffic Flows under Air Quality Constraints:
Two-Stage Stochastic Optimization Application
Student: Xiugang Li
Instructor: Dr. L. Ntaimo
Dec. 11, 2007
1. Abstract
The air pollution from vehicles is one of the significant problems faced by the
developed country such as the United States, and by the developing country such as
China in which motor vehicles increase very rapidly. In a metropolitan area, the air
pollutant concentrations are significant largely due to heavy traffic flows and traffic
congestions. Once the concentrations exceed the limits, it is difficult to adjust the traffic
flows to comply with the air quality standards. Therefore, it is necessary and very
beneficial to regulate traffic flows in order to comply with the air quality standards during
the planning stage considering the uncertainties of traffic flows, such as turning ratio.
This is especially important for sensitive and large exposure locations such as hospitals,
schools, gas stations in heavy traffic areas.
In this paper the authors develop an approach to regulate the traffic flows under
air quality constraints with two-stage stochastic programming. The cloverleaf interchange
is modeled as an example of uninterrupted traffic flow network. The model is formulated
based on the assumption of constant emission factors for a highway link and the
assumption of worst wind conditions. The traffic turning ratio on one entrance is assumed
to be constant, and the ratio on other entrances may have various values with
probabilities. The L-shaped algorithm is implemented to solve this two-stage random
recourse model. The results show that L-shaped algorithm solves the model efficiently.
The derived maximum flow rate is a very useful reference for transportation planners to
regulate the traffic flows during the planning stage.
1
2. Introduction and Literature Review
The air pollution from vehicles is one of the significant problems faced by the
developed country such as the United States (U.S.), and by the developing country such
as China in which motor vehicles increase very rapidly. According to the published air
quality data (U.S. Environmental Protection Agency, 2007), the monitored pollutant
concentrations exceeded the limits of the National Ambient Air Quality Standards (U.S.
Environmental Protection Agency, 2004) in many metropolitan areas. Areas that have
failed to meet federal standards for ambient air quality are designated as nonattainment
areas. In Texas the nonattainment areas include Houston-Galveston-Brazoria (HGB),
Dallas–Fort Worth (DFW), Beaumont–Port Arthur (BPA), San Antonio (SA), and El
Paso (ELP).
Vehicle emissions have significant negative impacts on health. Carbon Monoxide
(CO) can cause harmful health effects by reducing oxygen delivery to the body's organs
(U.S. Environmental Protection Agency, 2006). Ozone can cause a variety of health
problems such as chest pain and coughing (U.S. Environmental Protection Agency,
2006). Fine particles can affect the heart and lungs and cause serious health effects, and
oxides of nitrogen (NOx) can cause the disease of lung (U.S. Environmental Protection
Agency, 2006).
The Ambient Air Quality Standards (U.S. Environmental Protection Agency,
2004) set limits to protect public health, including the health of sensitive populations such
as asthmatics, children, and the elderly, and to protect public welfare, including
protection against decreased visibility, damage to animals, crops, vegetation, and
buildings.
In a metropolitan area, the air pollutant concentrations are significant largely due
to heavy traffic flows and traffic congestions. Once the concentrations exceed the limits,
it is difficult to adjust the traffic flows to comply with the air quality standards.
Therefore, it is necessary and very beneficial to develop strategies to regulate traffic
flows in order to comply with the air quality standards during the planning stage
considering the impacts of traffic flow, land use, traffic management, and air quality
control. This is especially important for sensitive and large exposure locations such as
hospitals, schools, gas stations in heavy traffic areas.
2
Currently highway capacity is defined as the maximum hourly flow rate at which
vehicles or persons can reasonably be expected to traverse a point or uniform section of a
lane or roadway during a given time period under prevailing roadway, traffic, and control
conditions (Garber and Hoel, 2002) . The calculating method is described in the Highway
Capacity Manual (Transportation Research Board, 2000).
In addition to highway capacity, Li et al. (2005) define traffic capacity under air
quality constrains as the maximum hourly flow rate at which vehicles or persons can
reasonably be expected to traverse a point or uniform section of a lane or roadway during
a given time period without generating air pollutions exceeding limits of air quality
standard. Li et al. (2005) developed a methodology to estimate the traffic capacity under
air quality constraints for a highway link. In this paper the authors extend the
methodology for an uninterrupted traffic flow network, such as a cloverleaf interchange.
Furthermore the uncertainties of traffic-flow turning ratios are considered in the proposed
two-stage random-recourse stochastic programming model to regulate the traffic flows
under air quality constraints.
Stochastic programming has been applied successfully in many fields (Birge and
Louveaux, 1997; Ntaimo and Sen, 2005), including the application in transportation
(Powell and Topaloglu, 2003). One of the advantages of stochastic programming is to
provide an adapted way to deal with the uncertainties in the modeling process. Many
algorithms have been proposed to solve stochastic programming, such as L-shaped
algorithm (Van Slyke and Wets, 1969) and the extensions including multi-cut algorithms
(Birge and Louveaux, 1988), regularized decomposition method (Ruszczynski, 1986),
and stochastic decomposition (Higle and Sen, 1996). In this paper, the L-shaped
algorithm is implemented to solve the formulated model.
3. Formal Problem Statement
3.1 Problem Description
The cloverleaf interchange is one of the examples of uninterrupted traffic-flow
network. Shown in Figure 1, the cloverleaf interchange connects two major two-direction
highways, and has very heavy traffic especially during traffic peak-hours. Due to the
heavy traffic the concentrations of air pollution may exceed the air quality limits, which
3
would be harmful to humans. In Figure 1, the air pollution receptor location could be a
school, hospital or gas station. The interchange has four entrances. Traffic flow rates of
left-turn, going through, and right-turn respectively on each entrance are q1 to q3, q4 to q6,
q7 to q9, q10 to q12 respectively. Based on the highway capacity, the interchange is divided
into 28 highway links, shown in Figure 1.
q9 q8 q7
10 5
Air pollution
receptor location
q10
q11
q12
16
9 4
23
27
17
q6
q5
q4
22
26
18
19
20
14
15
8 3
11
12
13
28
25
24
21
7 2
6 1
q1 q2 q3
Figure 1 Traffic flows and highway links of a cloverleaf interchange
We need to maximize the traffic flow rates entering the interchange while the air
pollution concentration at the receptor location should be less than the limit. The ratios of
traffic flow rates between the two major highways should be within a range to represent
the traffic flow phenomenon in the real world. The ratio of the traffic flow rates between
the two directions of each major highway should also be within a reasonable range. The
authors assume the left-turning ratio and right-turning ratio on one of entrance, such as
4
entrance 1, as constants. Then the left-turning ratios and right-turning ratios on other
entrances may have various values with specified probabilities. Therefore the two-stage
random-recourse stochastic programming model is formulated to maximize the entrance
flows.
3.2 Emission Factor and Air Quality Modeling
Emission factor and air quality modeling gives the relationship between traffic
flow rate and air pollution concentration. Emission factor is defined as the amount of
emissions exhausted from a type of vehicle per unit running length. According to U.S.
EPA, MOBILE6.2 model (U.S. Environmental Protection Agency, 2003) is used to
compute the emission factors. With the input of highway geometry, traffic flow rate,
emission factor, wind conditions, air quality model generates the concentration of air
pollution at a given receptor location. There are numerous air quality models, such as
CAR-FMI (Levitin, et al, 2005). In this paper, a widely applied model CALINE4
(Benson, 1992) is used to compute the air pollution concentration. For given constant
wind speed, wind direction, emission factor, highway link geometry, and receptor
location, the air pollution concentration generated from CALINE4 model is proportion to
the traffic flow rate on a single highway link. Therefore, in this paper the authors assume
the emission factor is a constant for each highway link. Then the worst wind direction is
also a constant for a given highway link. The normally used worst wind speed is 1m/s in
CALINE4 model. These worst wind conditions are used to assure that the air pollution
concentration must not exceed the air quality standard limit. With the worst wind
conditions, the pollution concentration cj at a given receptor location is computed for
each highway link j. Then the coefficient Zj is defined as
Zj =
cj
vj
where v j is traffic flow rate on link j.
12
v j = ∑ d ij qi
i =1
⎧1
d ij = ⎨
⎩0
if qi passes link j
if qi does not pass link j
5
where d ij is a dummy variable.
Then for the highway interchange shown in Figure 1, the air pollution
concentration at a given receptor is
28
12
j =1
i =1
c = ∑ Z j v j = ∑ ai qi
The equation above is used in the following two-stage stochastic linear
programming model.
3.3 Model Formulation
For the optimization model below, the decision variables in the 1st stage are leftturning flow rate q1 , going-through flow rate q2 and right-turning flow rate q3 on the 1st
entrance. The 2nd stage decision variables are qiω , ∀i = 2,...,12 , which are traffic flow
rates on the 2nd, 3rd and 4th entrances for each scenario ω of random turning ratios.
The data in the model are represented with the following symbols.
The 1st stage:
l1 : left-turning ratio on the 1st entrance
C j : highway capacity of link j, ∀j = 1, 2, 21, 26
r1 : right-turning ratio on the 1st entrance
The 2nd stage:
C j : highway capacity of link j , ∀j = 3,..., 20, 22,..., 25, 27, 28
lkω : left-turning ratio on entrance k , ∀k = 2,3, 4 , for each scenario ω
rkω : right-turning ratio on entrance k , ∀k = 2,3, 4 , for each scenario ω
bsn : lower bound of flow ratio between north-south direction
tsn : upper bound of flow ratio between north-south direction
bew : lower bound of flow ratio between east-west direction
tew : upper bound of flow ratio between east-west direction
b1 : lower bound of flow ratio between the two major higways
b2 : upper bound of flow ratio between the two major higways
6
ai : coefficient of air pollution for entrance traffic flow i , ∀i = 1,...,12
c : limit of air pollution
b : background concentration of air pollution
The model is formulated as follows.
⎛ 3
i)⎞
max ⎜ ∑ qi + Eωi f ( q1 , q2 , q3 , ω
⎟
⎝ i =1
⎠
s.t.
3
∑q
i
≤ C1
∑q
≤ C2
i =1
2
i =1
i
q1 ≤ C26
q3 ≤ C21
q1 − q2l1 = 0
q3 − q2 r1 = 0
qi ≥ 0, ∀i = 1, 2,3
i,
For each outcome ω of ω
f ( q1 , q2 , q3 , ω ) = max
12
∑ qω
i =3
i
s.t.
∑
i =1,2,10
qiω ≤ C3
∑ qω ≤ C
i
i = 2,10
4
∑
qiω ≤ C5
∑
qiω ≤ C6
i = 2,6,10
i = 4,8,12
∑ qω ≤ C
i = 4,8
i
7
7
∑
i = 4,7,8
qiω ≤ C8
∑ qω ≤ C
i =7,8
∑
i =7,8,9
i
9
qiω ≤ C10
∑
i =10,11,12
∑
i =10,11
qiω ≤ C11
qiω ≤ C12
∑
qiω ≤ C13
i =7,10,11
∑ qω ≤ C
i
i =7,11
∑
i =3,7,11
14
qiω ≤ C15
∑ qω ≤ C
i
i =1,5,9
16
∑ qω ≤ C
i =1,5
i
17
∑ qω ≤ C
i
i =1,4,5
18
∑ qω ≤ C
i = 4,5
∑
i = 4,5,6
i
19
qiω ≤ C20
q6ω ≤ C22
q9ω ≤ C23
q12ω ≤ C24
q10ω ≤ C25
8
q4ω ≤ C27
q7ω ≤ C28
q4ω − q5ω l2ω = 0
q6ω − q5ω r2ω = 0
q7ω − q8ω l3ω = 0
q9ω − q8ω r3ω = 0
ω ω
q10ω − q11
l4 = 0
q12ω − q11ω r4ω = 0
3
9
i =1
i =7
∑ bsn qiω − ∑ qiω ≤ 0
9
3
∑q − ∑t
ω
i =7
6
i
i =1
12
∑b
i =4
qω ≤ 0
sn i
ω
ω
ew qi − ∑ qi ≤ 0
i =10
12
6
i =10
i =4
∑ qiω − ∑ tewqiω ≤ 0
3
9
6
12
i =1
i =7
i =4
i =10
∑ b1qiω + ∑ b1qiω − ∑ qiω − ∑ qiω ≤ 0
3
9
6
12
i =1
i =7
i =4
i =10
− ∑ b2 qiω − ∑ b2 qiω + ∑ qiω + ∑ qiω ≤ 0
12
∑ a qω ≤ c
i =1
i i
qiω ≥ 0, ∀i = 4,...,12
4. Solution Approach
The proposed two-stage random-recourse stochastic linear programming model is
solved with the L-shaped algorithm. In mini-project 2 of this course the algorithm is
implemented to solve the problems with random right-hand-side values. In this paper the
implementation is extended to solve problems with random recourses.
9
4.1 L-Shaped Algorithm
The L-shape algorithm is described as follows (Ntaimo, 2007; Birge and
Louveaux, 1997).
Step 0: Initialization
Let K = 0, LB = −∞, UB = ∞, ε >0.
Get x 0 by solving
min C T x
s.t. Ax = b
x≥0
Step 1: Solve Sub-problems
For s = 1, 2,..., S
Solve f sK = min qsT y
s.t. Ws y = rs − Ts x k
If infeasible for some s, generate feasibility cut:
Get dual ext. ray µsK
Compute α K = ( µsK ) rs , β KT = ( µsK ) Ts
T
T
Go to Step 2
Else if feasible for all s, generate optimality cut:
Get dual solution π sK
Compute α K = ∑ (π sK ) rs ps , β KT = ∑ (π sK ) Ts ps
S
T
s =1
S
s =1
Compute upper bound of objective value:
V K = C T x K + ∑ ps f sK , UB = min {V K ,UB}
S
s =1
If update, set incumbent solution x* ← x K
Step 2: Add Cut to Master Problem and Solve
If some sub-problem is infeasible, add β KT x ≥ α K
Else add β KT x + η ≥ α K
Solve master problem to get solution ( x K +1 ,η K +1 ) and
10
T
optimal objective value V K +1
LB = max {V K +1 , LB}
Let θ K ≡ iteration index set at which optimality cut is generated
The master program is
V K +1 = min C T x + η
s.t. Ax
=b
β x + η ≥ αt , t ∈ θ K
T
t
β tT x
x
≥ αt , t ∉θ K
≥0
Step 3: Termination
If UB − LB ≤ ε UB
Stop, and report x* that corresponds to UB
Else K ← K + 1 , return to Step 1.
4.2 Algorithm Implementation
The L-shaped algorithm is implemented to solve models with random recourse
and random right-hand-side values. In this paper the model has random recourses so the
implementation of the L-shaped algorithm in mini-project 2 is extended to solve the
random recourse model. The algorithm is implemented using Microsoft Visual Studio
2005 (Microsoft Corporation, 2005) and CPLEX 9.1.3 (ILOG, S. A., 2003a) and the
Callable Library (ILOG, S. A., 2003b). The computer program reads the data values and
probabilities in the STOC file, and changes the values of Ws and rs in the sub-problem
constraints Ws y = rs − Ts x k for each scenario s with Callable Library functions
CPXchgcoeflist and CPXchgrhs. For each iteration the sub-problems generate a cut
which is added to the master program with the function CPXaddrows.
The wall-clock time is the run time of entry algorithm to the end of algorithm,
which is larger than the CPU time. The CPU time is the run time of calling CPLEX to
optimize the sub-problem and the master program. For each iteration, sum the run time of
CPXdualopt(env, lp) or CPXprimopt (env, lp) in the sub-problem and the master
program; Then sum the run time for all iterations.
11
5. Computational Experiments
The computational experiments are designed to test three factors, such as air
pollution receptor location, traffic flow turning-ratio, and number of probabilities for
each coefficient. For each of the three factors, two values are tested. Then totally we have
8 instances.
The data used for testing include traffic flow turning ratios, highway capacities,
emission factors and air quality coefficients. These data can be found in the appendix.
For the 1st instance, the optimal objective value is 9280.53 veh/hour; the master
solutions are q1=177.762, q2=1185.08, 237.016. The objective value converges to
percent gap of 1.46555e-6 in 5 iterations. The upper bound and lower bound of objective
value for each iteration are shown in Figure 2. The total number of scenario is 15625. The
wall clock time and CPU time are 7.781 sec and 5.407 sec respectively. The results for
other instances are shown in the appendix.
Objective Value
10000
9900
Lower bound
Upper bound
9800
9700
9600
9500
9400
9300
9200
9100
9000
8900
0
1
2
3
4
5
Iteration Number
Figure 2 Lower and upper bound of objective value for Instance 1
The computational results show that:
(1) The maximum traffic flow rate is larger when the receptor location is farer. This
is reasonable because the air pollution concentration decreases with the distance
as other parameters keep constant.
12
(2) The 1st stage solution of traffic flow rate may change significantly with traffic
turning ratio. This is reasonable because the traffic turning ratio changes the
balance between different directions and entrances.
(3) The maximum traffic flow rate may change a few with traffic turning ratio.
(4) When the number of probabilities for each coefficient increases from 3 to 6, the
CPU time and wall clock time increase significantly.
(5) L-shaped algorithm solves the model in this paper efficiently. The CPU time is
less than 10 seconds.
6. Conclusions and Future Work
In this paper the authors develop an approach to regulate the traffic flows under
air quality constraints with two-stage stochastic programming. The derived maximum
flow rate is a very useful reference for transportation planners to regulate the traffic flows
during the planning stage. The cloverleaf interchange is modeled as an example of
uninterrupted traffic flow network. The model is formulated based on the assumption of
constant emission factors for a highway link and the assumption of worst wind
conditions. The traffic turning ratio on one entrance is assumed to be constant, and the
ratio on other entrances may have various values with probabilities. The L-shaped
algorithm is implemented to solve this two-stage random recourse model. The results
show that L-shaped algorithm solves the model efficiently. The traffic flow ratio changes
the maximum flow rate a few, and changes the 1st stage solution significantly.
The future work includes the modeling of a larger highway network other than
cloverleaf interchange. More efficient algorithms may be implemented to solve the large
highway network problem.
For this project, I completed the code of the multicut L-shaped algorithm, and
more work is needed to complete the implementation.
7. References
Benson, P. 1992. A review of the development and application of the CALINE3 and 4
models, Atmospheric Environment, 26B(3), 379–390.
Birge, J.R. and L. Louveaux. 1988. A multicut algorithm for two-stage stochastic linear
programs, European Journal of Operational Research, 34, 384-392.
13
Birge, J.R. and L. Louveaux. 1997. Introduction to Stochastic Programming, Springer,
New York.
Garber, N.J. and L.A. Hoel. 2002. Traffic and Highway Engineering. The Wadsworth
Group: Pacific Grove, California.
Higle, J.L. and S. Sen. 1996. Stochastic Decomposition: A Statistical Method for Large
Scale Stochastic Linear Programming. Kluwer Academic Publishers, Norwell, MA.
ILOG, S. A. 2003a. ILOG CPLEX 9.0 User’s Manual.
ILOG, S. A. 2003b. ILOG CPLEX 9.0 Callable Library Reference Manual.
Levitin, J., J. Härkönenb, J. Kukkonenb and J. Nikmo. 2005. Evaluation of the CALINE4
and CAR-FMI models against measurements near a major road, Atmospheric
Environment, 39(25), 4439-4452.
Li, X.G., G.Q. Li, S.S. Pang, M.A. Stubblefield, C.G. Wilmot. (2005). Traffic Capacity
under Air Quality Constraints. Advances in Transportation Studies: an International
Journal, B6: 73-84.
Microsoft Corporation. 2005. Microsoft Visual Studio 2005.
http://msdn2.microsoft.com/en-us/ie/bb188238.aspx, accessed on December 6, 2007.
Ntaimo, L. and S. Sen. 2005. The million-variable “march” for stochastic combinatorial
optimization, Journal of Global Optimization, 32(3), 385-400.
Ntaimo, L. 2007. Lecture Notes on ISEN689 Large-Scale Stochastic Optimization. Texas
A&M University, College Station.
Powell, W.B. and H. Topaloglu. 2003. Stochastic programming in transportation and
logistics. In Stochastic Programming: Handbooks in Operations Research and
Management Science, Volume 10, Edited by A. Ruszczynski and A. Shapiro, New
York, NY.
Ruszczynski, A. 1986. A regularized decomposition methods for minimizing a sum of
polyhedral functions. Mathematical Programming, 35, 309-333.
Transportation Research Board. 2000. Highway Capacity Manual 2000. National
Research Council: Washington D.C.
U.S. Environmental Protection Agency. 2003. User’s Guide to MOBILE6.1 and
MOBILE6.2: Mobile Source Emission Factor Model. EPA420-R-03-010, Ann Arbor,
Michigan.
14
U.S. Environmental Protection Agency. 2004. National Ambient Air Quality Standards
(NAAQS). Ann Arbor, Michigan.
U.S. Environmental Protection Agency. 2006. Six Common Air Pollutants,
http://www.epa.gov/air/urbanair/6poll.html. Accessed on December 1, 2006.
U.S. Environmental Protection Agency. 2007. Air Data,
http://www.epa.gov/air/data/geosel.html, accessed on December 6, 2007.
Van Slyke, R.M. and R. Wets. 1969. L-shaped linear programs with applications to
optimal control and stochastic programming, SIAM Journal on Applied Mathematics,
17(4), 638-663.
8. Team Member Critique
None
15
9. Appendix
9.1 Computational results
Turning
Ratio 1
5 prob.
Objective value
9280.53
177.762,
Optical stage 1 solution 1185.08,
(q1,q2,q3)
237.016
CPU time
5.142
Number of iteration
5
3 prob.
9298.66
177.778,
1185.19,
237.037
0.187
5
Turning
Ratio 2
5 prob.
9206.52
444.444,
2962.96,
592.593
6.362
4
3 prob.
9231.75
444.444,
2962.96,
592.593
0.206
4
9.2 Test instance (model) data
Data used for modeling
Traffic-flow turning ratio at entrances
The 1 entrance The 2nd entrance The 3rd entrance
Ratio
Prob.
Ratio
Prob. Ratio
Prob.
0.05
0
0.05
0.25
0.05
0.25
0.10
1
0.10
0.5
0.10
0.5
0.15
0
0.15
0.25
0.15
0.25
0.05
0
0.05
0.3
0.05
0.3
0.10
1
0.10
0.5
0.10
0.5
0.15
0
0.15
0.2
0.15
0.2
The 4th entrance
Ratio
Prob.
0.05
0.25
0.10
0.5
0.15
0.25
0.05
0.3
0.10
0.5
0.15
0.2
Traffic-flow capacity at entrances
The 1st entrance The 2nd entrance The 3rd entrance
1800
1800
1800
1800
1800
1800
6000
6000
6000
The 4th entrance
1800
1800
6000
Emission factor of entered traffic flow
The 1 entrance The 2nd entrance The 3rd entrance
30
30
30
26
26
26
22
22
22
The 4th entrance
30
26
22
st
Left-turn
Right-turn
Left-turn
Right-turn
Goingthrough
st
Left-turn
Right-turn
Goingthrough
16
Coefficient of traffic flow for Point B
The 1 entrance The 2nd entrance The 3rd entrance
0.00005
0.00003
0.000035
0.000035
0.000045
0.000035
0.000035
0.00004
0.000045
st
Left-turn
Right-turn
Goingthrough
The 4th entrance
0.000035
0.000045
0.00005
The CO concentration limit is 35 ppm according to the National Ambient Air Quality
Standard (U.S. Environmental Protection Agency, 2004).
background concentration of air pollution, assumed to be 0.
Examples of the test data are shown as the following three files.
NAME
ROWS
N OBJM
L L1
L L2
L L26
L L21
E NL
E NR
L L3
L L4
L L5
L L6
L L7
L L8
L L9
L L10
L L11
L L12
L L13
L L14
L L15
L L16
L L17
L L18
L L19
L L20
L L22
L L23
L L24
L L25
L L27
L L28
E SL
E SR
E EL
E ER
c:\temp\pjttxt
17
E WL
E WR
L SNB1
L SNB2
L EWB1
L EWB2
L CB1
L CB2
L AQ
COLUMNS
C1
C1
C1
C1
C1
C1
C1
C2
C2
C2
C2
C2
C2
C2
C3
C3
C3
C3
C3
C4
C4
C4
C4
C4
C4
C4
C5
C5
C5
C5
C5
C5
C5
C6
C6
C6
C6
C6
C7
C7
C7
C7
C7
C7
C7
C8
C8
OBJM
L2
NL
L16
L18
SNB2
CB2
OBJM
L2
NR
L4
SNB1
CB1
AQ
OBJM
L21
L15
SNB2
CB2
OBJM
L7
L18
L20
WL
EWB2
CB2
OBJM
L17
L19
WL
EWB1
CB1
AQ
OBJM
L20
WR
EWB2
CB2
OBJM
L9
L13
L15
SL
SNB2
CB2
OBJM
L7
-1
1
1
1
1
-2.5
-2.5
-1
1
-0.2
1
0.4
0.4
0.00481
-1
1
1
-2.5
-2.5
-1
1
1
1
1
-2.5
1
-1
1
1
-0.15
0.4
-1
0.00481
-1
1
1
-2.5
1
-1
1
1
1
1
1
-2.5
-1
1
18
L1
L26
L3
L17
SNB1
CB1
AQ
L1
NL
L3
L5
SNB2
CB2
1
1
1
1
0.4
0.4
0.0057
1
-0.15
1
1
-2.5
-2.5
L1
NR
SNB1
CB1
AQ
L6
L8
L19
L27
EWB1
CB1
AQ
L16
L18
L20
WR
EWB2
CB2
1
1
0.4
0.4
0.00205
1
1
1
1
0.4
-1
0.00584
1
1
1
-0.2
-2.5
1
L5
L22
EWB1
CB1
AQ
L8
L10
L14
L28
SNB1
CB1
AQ
L6
L8
1
1
0.4
-1
0.00328
1
1
1
1
-1
0.4
0.005
1
1
C8
C8
C8
C8
C8
C9
C9
C9
C9
C9
C10
C10
C10
C10
C10
C10
C10
C11
C11
C11
C11
C11
C11
C11
C12
C12
C12
C12
C12
L9
SL
SNB1
CB1
AQ
OBJM
L16
SR
SNB2
CB2
OBJM
L4
L11
L13
EL
EWB2
CB2
OBJM
L12
L14
EL
EWB1
CB1
AQ
OBJM
L11
ER
EWB2
CB2
1
-0.15
-1
0.4
0.00348
-1
1
1
1
-2.5
-1
1
1
1
1
1
1
-1
1
1
-0.15
-1
-1
0.00348
-1
1
1
1
1
L10
SR
SNB2
CB2
1
-0.2
1
-2.5
L10
L23
SNB1
CB1
AQ
L3
L5
L12
L25
EWB1
CB1
AQ
L11
L13
L15
ER
EWB2
CB2
1
1
-1
0.4
0.00205
1
1
1
1
-1
-1
0.00584
1
1
1
-0.2
1
1
L6
L24
EWB1
CB1
AQ
1
1
-1
-1
0.00164
RHS
rhs
rhs
rhs
rhs
rhs
rhs
rhs
rhs
rhs
rhs
rhs
rhs
rhs
rhs
rhs
ENDATA
TIME
PERIODS
C1
C4
ENDATA
L1
L26
L3
L5
L7
L9
L11
L13
L15
L17
L19
L22
L24
L27
AQ
4000
1800
6000
4000
4000
4000
4000
6000
4000
4000
4000
1800
1800
1800
35
pjt
L1
L3
TIME1
TIME2
19
L2
L21
L4
L6
L8
L10
L12
L14
L16
L18
L20
L23
L25
L28
4000
1800
4000
4000
6000
4000
4000
4000
4000
6000
4000
1800
1800
1800
STOCH
INDEP
C8
C8
C8
C8
C8
C8
C8
C8
C8
C8
C11
C11
C11
C11
C11
C11
C11
C11
C11
C11
C5
C5
C5
C5
C5
C5
C5
C5
C5
C5
ENDATA
pjt
DISCRETE
SL
-0.05
SL
-0.1
SL
-0.15
SL
-0.2
SL
-0.25
SR
-0.1
SR
-0.15
SR
-0.2
SR
-0.25
SR
-0.3
EL
-0.05
EL
-0.1
EL
-0.15
EL
-0.2
EL
-0.25
ER
-0.1
ER
-0.15
ER
-0.2
ER
-0.25
ER
-0.3
WL
-0.05
WL
-0.1
WL
-0.15
WL
-0.2
WL
-0.25
WR
-0.1
WR
-0.15
WR
-0.2
WR
-0.25
WR
-0.3
0.1
0.15
0.5
0.15
0.1
0.1
0.15
0.5
0.15
0.1
0.1
0.15
0.5
0.15
0.1
0.1
0.15
0.5
0.15
0.1
0.1
0.15
0.5
0.15
0.1
0.1
0.15
0.5
0.15
0.1
20
9.3 Pseudo Code, etc.
Examples of code are shown below.
////////////////////////////////////////////////////////
// Begin L-shaped algorithm here
////////////////////////////////////////////////////////
// Initializations
iterate = true;
num_iters = 0;
ubound = CPX_INFBOUND;
walltime=clock();
do {
status=sublpobj.Solvesublp(solnx);
clkduration=clkduration+sublpobj.GetClockTime();
infis=sublpobj.Getsolnstatus();
uboundnew=sublpobj.Getubound(masterobj.Getstage1objval());
if (ubound>uboundnew) {
ubound=uboundnew;
masterobj.Setincumbsoln(ubound);
}
myfile <<num_iters<<"
"<<ubound;
status=masterobj.Addbenderscut(sublpobj.Getbenderslhscoefs(),subl
pobj.Getbendersrhs(),infis);
status=masterobj.Solvemaster();
clkduration=clkduration+masterobj.GetClockTime();
solnx=masterobj.Getsoln();
lbound=masterobj.Getmax(masterobj.Getobjval(),lbound);
myfile <<"
"<<lbound<<"\n";
if (ubound != 0) percent_gap=fabs((uboundlbound)/ubound);
if (display) {
cout << endl << "ITERATION " << num_iters << "
problem " << argv[1] << endl;
cout << " [LB, UB]: [" << lbound << ", " << ubound
<<"]" << endl;
cout << " Percent gap: " << percent_gap << endl;
}
if (percent_gap<0.00001) iterate=0;
if (ubound==0) {
if (fabs(ubound-lbound)<0.001) iterate=0;
}
num_iters=num_iters+1;
} while (iterate);
walltime=clock()-walltime;
duration=(double)walltime/CLOCKS_PER_SEC;
cout<<"\nwall clock time: "<<duration<<"\n";
cout<<"\nCPU time: "<<clkduration<<"\n";
21
int Sublp::Readstocfile(const char *filenameprefix)
/**
* Reads the STOC file data
* @param TIME file name.
* @return 0 if TIME file is successfully read, otherwise return a
nonzero integer.
*/
{
const string &timefilename=string(filenameprefix)+".sto";
char field1[NAMELEN];
char field2[NAMELEN];
char field3[NAMELEN];
char field4[NAMELEN];
char buffer[LENGTH];
int i;
char *tempst;
string stoccolname[5000];
string stocrhsname[5000];
double stocvalue[5000];
double stocprob[5000];
int numline;
// Open STOC file for Reading
ifstream fin(timefilename.c_str());
if(!fin.is_open()) {
cerr << "Reader: Readstocfile()" << endl;
cerr << "Reader: Unable to open STOC file " << timefilename << "
for reading!"<< endl;
return(1);
}
// Process the STOC file
if (fin.getline(buffer, LENGTH)) {
//read first line
sscanf(buffer, "%s %s", field1, field2);
}
if (fin.getline(buffer, LENGTH)){
//read second line
sscanf(buffer, "%s%s", field1, field2);
}
i=0;
do{
fin.getline(buffer, LENGTH);
sscanf(buffer, "%s %s %s %s", field1,field2,field3,field4);
stoccolname[i]=field1;
stocrhsname[i]=field2;
stocvalue[i]=strtod(field3,&tempst);
stocprob[i]=strtod(field4,&tempst);
i=i+1;
} while (strcmp(field1, "ENDATA") != 0);
numline=i-1;
numstovar=0;
int jj=0; //index for variables
//compute how many stoch variable, and how many prob. for each variable
string field6;
field6=stocrhsname[0];
22
numprob[0]=1;
varname[0]=stocrhsname[0];
colname[0]=stoccolname[0];
varvalue[0][0]=stocvalue[0];
probvalue[0][0]=stocprob[0];
cout << "probvalue[0][0]" << varvalue[0][0]<<" "<<colname[0]<<"
"<<varname[0]<<endl;
for (i=1; i<numline ;i++) {
if (stocrhsname[i]==field6) {
numprob[jj]=numprob[jj]+1;
varvalue[jj][numprob[jj]-1]=stocvalue[i];
probvalue[jj][numprob[jj]-1]=stocprob[i];
}
else {
jj=jj+1;
numprob[jj]=1;
field6=stocrhsname[i];
varname[jj]=stocrhsname[i];
colname[jj]=stoccolname[i];
varvalue[jj][numprob[jj]-1]=stocvalue[i];
probvalue[jj][numprob[jj]-1]=stocprob[i];
}
cout << "probvalue["<<jj<<"]["<<numprob[jj]-1<<"]" <<
varvalue[jj][numprob[jj]-1]<<" "<<colname[jj]<<"
"<<varname[jj]<<endl;
}
numstovar=jj+1;
return (0);
} // ************************ End Readstocfile()
************************
23
int Sublp::Solvesublp(double *solnx)
/**
* Solves subproblem and stores the solution
* @param solnx master program solution x
* @return 0 if success, otherwise returns a nonzero integer
*/
{
#ifdef DEBUG_SUBLP
cerr << endl << "Sublp::Solvesublp() ..." << endl;
#endif
int *rowindices;
int solstat;
int j;
// Array to store row indices
// Integer to indicate status of CPLEX solution
// counter
inf_sub = false; // Initialize as having a feasible subproblem
//--------------------Li
int is; //index
int ks; //index
int *jj;
jj=new int[10];
int j0,j1,j2,j3,j4,j5,j6,j7,j8,j9; //index
double ps=1; //prob of currrent scenario
double rhstemp=0;
double lhstemp[100];
for (j = 0; j < cur_ncolsT; j++)
lhstemp[j]=0;
double objvaluetemp=0;
double timed=0;
clktime=0;
double s; //number of scenarios
s=1;
for (is=0;is<numstovar;is++) {
s=s*numprob[is];
}
int rowindex;
int colindex;
for (j0=0;j0<numprob[0];j0++){
jj[0]=j0;
for (j1=0;j1<numprob[1];j1++){
jj[1]=j1;
for (j2=0;j2<numprob[2];j2++){
jj[2]=j2;
for (j3=0;j3<numprob[3];j3++){
jj[3]=j3;
for (j4=0;j4<numprob[4];j4++){
jj[4]=j4;
for (j5=0;j5<numprob[5];j5++){
24
jj[5]=j5;
for (is=0;is<numstovar;is++) {
if (is==0) {
status = CPXgetrowindex (env, lp, "SL",
&rowindex);
status = CPXgetcolindex (env, lp, "C8",
&colindex);
status = CPXchgcoeflist (env,
&colindex, &varvalue[is][jj[is]]);
}
if (is==1) {
status = CPXgetrowindex (env,
&rowindex);
status = CPXgetcolindex (env,
&colindex);
status = CPXchgcoeflist (env,
&colindex, &varvalue[is][jj[is]]);
}
if (is==2) {
status = CPXgetrowindex (env,
&rowindex);
status = CPXgetcolindex (env,
&colindex);
status = CPXchgcoeflist (env,
&colindex, &varvalue[is][jj[is]]);
}
if (is==3) {
status = CPXgetrowindex (env,
&rowindex);
status = CPXgetcolindex (env,
&colindex);
status = CPXchgcoeflist (env,
&colindex, &varvalue[is][jj[is]]);
}
if (is==4) {
status = CPXgetrowindex (env,
&rowindex);
status = CPXgetcolindex (env,
&colindex);
status = CPXchgcoeflist (env,
&colindex, &varvalue[is][jj[is]]);
}
if (is==5) {
status = CPXgetrowindex (env,
&rowindex);
status = CPXgetcolindex (env,
&colindex);
status = CPXchgcoeflist (env,
&colindex, &varvalue[is][jj[is]]);
}
ps=1;
for (is=0;is<numstovar;is++) {
ps=ps*probvalue[is][jj[is]];
}
25
lp, 1, &rowindex,
lp, "SR",
lp, "C8",
lp, 1, &rowindex,
lp, "EL",
lp, "C11",
lp, 1, &rowindex,
lp, "ER",
lp, "C11",
lp, 1, &rowindex,
lp, "WL",
lp, "C5",
lp, 1, &rowindex,
lp, "WR",
lp, "C5",
lp, 1, &rowindex,
rowindices = new int[cur_nrows];
// Set the indices
for (j = 0; j < cur_nrows; j++)
rowindices[j] = j;
// Compute subproblem RHS based on current first stage solution
// Note: The rhs = r - Tx and is stored in sublpPtr->rhsRho
Createsublprhs(solnx);
#ifdef DEBUG_SUBLP
cerr << endl << "Setting subproblem RHS" << endl;
#endif
// Set the RHS for this subproblem
status = CPXchgrhs(env, lp, sublpPtr->nrows, rowindices, sublpPtr>rhsRho);
if ( status ) {
cerr << endl << "Sublp::Solvesublp(.):" << endl;
cerr << "Failed to set the rhs" << endl;
cerr << "CPLEX error code: " << status << endl;
return (status);
}
#ifdef DEBUG_SUBLP
cerr << endl << "Sublp::Solvescensublps.):" << endl;
cerr << "Writing subproblem lp to file sub.lp " << endl;
status = CPXwriteprob(env, lp, "sub.lp", "LP");
if ( status ) {
cerr << "Sublp::Solvescensublps(.):" << endl;
cerr << "Failure to write subproblem lp to file, CPLEX
error code:" << status << endl;
cerr << "Exiting..." << endl;
return (status);
}
cerr << "Optimizing subproblem LP..." << endl;
#endif
timed=(double)clock()/CLOCKS_PER_SEC;
status = CPXdualopt (env, lp);
// use dual simplex
timed=(double)clock()/CLOCKS_PER_SEC-timed;
clktime=clktime+timed;
if ( status ) {
cerr << endl << "Sublp::Solvescensublps(.):" << endl;
cerr << "Failed to optimize subproblem!" << endl;
cerr << " CPLEX error code " << status << endl;
return (status);
}
#ifdef DEBUG_SUBLP
cerr << "Done optimizing subproblem LP" << endl;
#endif
// Get solution
26
status = CPXsolution (env, lp, &solstat, &objval, soln, sublpPtr>duals, NULL, NULL);
if (status) {
cerr << endl << "Sublp::Solvesublp(.):" << endl;
cerr << "Failed call to CPXsolution(.) to get subproblem
LP solution " << endl;
cerr << " CPLEX error code " << status << endl;
return (status);
}
if (solstat == 3) { //CPXSTAT_INFEASIBLE) { // unbounded dual
cout << "INFEASIBLE scenario subproblem LP. CPLEX solution
error code " << solstat << endl;
cout << " Bailing out..." << endl;
inf_sub = true;
// Got extreme ray
} else if(solstat != 1) { //Problem unbounded
cout << "INF OR UNBOUNDED scenario subproblem LP. CPLEX
solution error code " << solstat << endl;
cout << " Bailing out..." << endl;
return(solstat);
} // End if
// Display solution
#ifdef DEBUG_SUBLP
cerr << endl << "Sublp::Solvesublps: subproblem solution" <<
endl;
cerr << " Objective value = " << objval << endl;
cerr << " Primal Solution:" << endl;
for (j = 0; j < cur_ncols; j++) {
if (soln[j] > NONZERO_LB)
cerr << " " << sublpPtr->colnames[j] <<" = " << soln[j]
<< endl;
}
cerr << "All other variables equal to zero." << endl;
if (inf_sub == true)
cerr << " Dual Solution: Extreme Ray!" << endl;
else
cerr << " Dual Solution:" << endl;
for (j = 0; j < cur_nrows; j++) {
if (sublpPtr->duals[j] > NONZERO_LB)
cerr << " Row [" << j << "] = " << sublpPtr->duals[j] <<
endl;
}
cerr << "All other duals equal to zero." << endl;
#endif
// Compute Benders' cut coefs
Computebenderscut();
// Free memory
delete rowindices;
//--------------Li begin
27
rhstemp=rhstemp+ps*benders_rhs;
for (j = 0; j < cur_ncolsT; j++)
lhstemp[j]=lhstemp[j]+ps*benders_cutcoefs[j];
objvaluetemp=objvaluetemp+ps*objval;
}
}
}
}}}
// end of all scenarios
benders_rhs=rhstemp;
for (j = 0; j < cur_ncolsT; j++)
benders_cutcoefs[j]=lhstemp[j];
objval=objvaluetemp;
//---------------------------Li complete
delete jj;
return(0);
} //******************************* Solvescensublps
*************************************//
28
Download