gpt4 book ai didi

syntax-error - CPLEX中没有运算符

转载 作者:行者123 更新时间:2023-12-03 08:34:48 26 4
gpt4 key购买 nike

我在CPLEX中的代码中有一个错误:
运算符不适用于dvar int + [] [time] + dexpr float。

int i=...; //set of origins
int j=...; //set of destinations
int t=...;//set of time


//parameters
float al[origins][destinations][time]=...;//Proportion of all utilized vehicles that are dispatched

//variables
dvar int+ o[origins][destinations][time];//numbers of vehicles present at i at beginning of t
dvar int+ l[origins][destinations][time];//numbers of rented vehicles dispatched from i to j during t
dvar int+ e[origins][destinations][time];//numbers of unutilized vehicles dispatched from i to j during t

subject to{
constraint:
forall(i in origins, t in time:(t-1) in time)
o[i][t]== o[i][t-1]+ sum (j in destinations, t in time ) al[i][j][t] * e[j][i][t]- l[i][j][t-1];
}

我该如何解决这个错误?

最佳答案

您的决策变量o定义为具有3个索引,但是,在约束中,您仅使用两个索引。
另外,我认为

sum (j in destinations, t in time ) al[i][j][t] * e[j][i][t]-  l[i][j][t-1];
应写为(请注意附加括号)
sum (j in destinations, t in time ) (al[i][j][t] * e[j][i][t]-  l[i][j][t-1]);

关于syntax-error - CPLEX中没有运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62745501/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com