在 Cplex 中使用给定的概率分布对提前期建模

Model leadtimes with a given probability distribution in Cplex

对于我在 Cplex 中的整合问题,我想以给定的概率计算从始发站到网关站的行程时间(提前期)'emerge'。从网关到最终目的地的运输将取决于此结果。这是我的代码的简化版本,其中如果订单 n 在时间 t 从终端 i 运送到终端 j,则 x 为 1:

int leadtime[terminal, terminal] = ...;
dvar int+ x[terminal, terminal, time, order] in 0..1;

forall(i terminal, j in terminal, d in terminal, t in time, n in order) x[i,j,t,n] <= x[j,d,t+leadtime[i,j],n];

例如,起点和网关之间的提前期在80%的时间里等于1个时间段,在剩下的20%的时间里等于2个时间段。我想为此包括不同的概率分布。有没有办法对此建模?

非常感谢您! 亲切的问候

您可以使用一些场景和概率为您的数据编制索引,然后在每个场景中使用您的决策变量数组。

非常simple example in Making optimization simple

/*

现在让我们假设所有这些选项都有一些概率,我们需要在前一天预订公共汽车,但在早上实时,我们可能会以额外的价格预订一些额外的公共汽车。 (+10%) 这是随机优化。我们希望最小化平均成本。我们称额外的总线资源变量。 在 OPL 中,从确定性模型转移到随机模型非常简单: */

int nbKids=300;

{int} nbKidsScenarii={nbKids+i*10 | i in -10..2};
float proba[nbKidsScenarii]=[ 1, 1, 2, 2, 2 ,3 ,3 ,4,  5 ,10 ,50 ,10, 7];

assert sum(s in nbKidsScenarii) proba[s]==100; // total probability is 100

float costBus40=500;
float costBus30=400;

float costIncreaseIfLastMinute=1.1;

// number of buses booked in advance
dvar int+ nbBus40;
dvar int+ nbBus30;
// number of buses booked at the last minute which is far more expensive
// we call those recourse decision
dvar int+ nbBus40onTop[nbKidsScenarii] ;
dvar int+ nbBus30onTop[nbKidsScenarii] ;
 
minimize
 costBus40*nbBus40  +nbBus30*costBus30
 +
1/100*costIncreaseIfLastMinute*
sum(nbKids in nbKidsScenarii) proba[nbKids]*(costBus40*nbBus40onTop[nbKids]  +nbBus30onTop[nbKids]*costBus30);
 
subject to
{


 forall(nbKids in nbKidsScenarii)
   ctKids:40*(nbBus40+nbBus40onTop[nbKids])+(nbBus30+nbBus30onTop[nbKids])*30>=nbKids;
}

execute
{
writeln("nbBus40 = ",nbBus40);
writeln("nbBus30 = ",nbBus30);
writeln();
writeln("nbBus40 on top = ",nbBus40onTop);
writeln("nbBus30 on top = ",nbBus30onTop);
}

给予

// solution (optimal) with objective 3775.5
nbBus40 = 6
nbBus30 = 0
nbBus40 on top =  [0 0 0 0 0 0 0 0 1 0 0 1 2]
nbBus30 on top =  [0 0 0 0 0 1 1 1 0 2 2 1 0]

这是我的部分代码:

int leadtime = 1;
{int} leadtime_scenarios = {leadtime + a | a in 0..1};
float proba[leadtime_scenarios] = [0.1,0.9];
assert sum(s in leadtime_scenarios) proba[s] == 1;

minimize sum(i in terminal, j in terminal, t in time, n in order) exp_fixed_cost_g[i,j,t,n];

forall(i terminal, j in terminal, d in terminal, t in time, n in order, s in scenario) x[i,j,t,n] <= x[j,d,t+leadtime[i,j,s],n];
forall(i in terminal, j in terminal, t in time, n in order) exp_fixed_cost_g[i,j,t,n] >= fixed_cost[i,j] - Z*(1-x[i,j,t,n]); //Z is a large value

非常感谢您的帮助。亲切的问候