OPL 中有字符串连接吗?
Is there string concatenation in OPL?
我想知道 IBM/ILOG OPL 语言中是否有字符串连接 syntax/function?我在我的 OPL 模型中使用了 +
,例如:
{names[i] + "_" | i in I}
但出现错误。
我用的是CPLEX studio 12.6,翻了下帮助也没找到这个功能。谷歌搜索显示 int 数组有 append,但 String 不多。任何关于如何在模型本身中进行字符串连接的指针。
做字符串连接你可以使用脚本。
range r=1..3;
string names[i in r]="item";
execute
{
for(var i in r) names[i]+=i;
writeln(names);
}
这给出 ["item1" "item2" "item3"]
问候
我想知道 IBM/ILOG OPL 语言中是否有字符串连接 syntax/function?我在我的 OPL 模型中使用了 +
,例如:
{names[i] + "_" | i in I}
但出现错误。
我用的是CPLEX studio 12.6,翻了下帮助也没找到这个功能。谷歌搜索显示 int 数组有 append,但 String 不多。任何关于如何在模型本身中进行字符串连接的指针。
做字符串连接你可以使用脚本。
range r=1..3;
string names[i in r]="item";
execute
{
for(var i in r) names[i]+=i;
writeln(names);
}
这给出 ["item1" "item2" "item3"]
问候