以下代码有什么问题?

what is the problem with the following code?

我有很多设施。我想要选择和分配的设施的索引。最后,我想要一个 CSV 输出来显示每个设施。但是我不想像 [24 15 30 ...] 那样显示它们,而是想像这样将它们分开:[24,25,30,...]。下面的代码给我一个错误。是否可以让我知道问题出在哪里? 错误是 1。元素 "string" 不在 OPL 模型中。 2.element 集线器从未被使用过。 (但正如你所见,我使用了它)

{int} hub = { s | s in facilities : y[s] == 1 };
//Output in a CSV file
execute{
string hubs="[";
for (var i=0; i<hub.length-1;i++){
  hubs += hub[i]+",";
}
hubs += hub[hub.length-1]+"]";
var f=new IloOplOutputFile("1.csv");
f.writeln("Facilities");
f.writeln(hubs);
f.close();
}
{int} facilities=asSet(1..3);

int y[facilities]=[1,0,1];

 {int} hub = { s | s in facilities : y[s] == 1 };
//Output in a CSV file
execute{
var f=new IloOplOutputFile("1.csv");
f.writeln("Facilities =");
var hubs="[";
for (var i in hub){
  hubs += i+",";
}
hubs+="]";


f.writeln(hubs);
f.close();
}

这将给出:

Facilities =
[1,3,]

PS:

{int} facilities=asSet(1..3);

int y[facilities]=[1,0,1];

 {int} hub = { s | s in facilities : y[s] == 1 };
//Output in a CSV file
execute{
var f=new IloOplOutputFile("1.csv");
f.writeln("Facilities =");
var hubs="[";
for (var i in hub){
  hubs += i;
  if (i!=Opl.last(hub)) hubs+=",";
}
hubs+="]";


f.writeln(hubs);
f.close();
}

给予

Facilities =
[1,3]