Hi,
You should define Employee but you have not.
{string} Employee={"A","B","C"};
{string} Location={"Paris","Rouen"};
string Preference2[Employee]=["Paris","Paris","Rouen"];
float weight1[e in Employee][l in Location] = (l == Preference2[e]) ? 3 : 0 ;
float weight2[e in Employee][l in Location] = (l == Preference2[e]) ? 2 : 0 ;
float weight3[e in Employee][l in Location] = (l == Preference2[e]) ? 1 : 0 ;
float weightN[n in 1..3][e in Employee][l in Location] = (l == Preference2[e]) ? (4-n) : 0 ;
execute
{
writeln(weight1,weight2,weight3);
writeln(weightN);
}
works fine
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]
------------------------------
Original Message:
Sent: Tue March 22, 2022 03:19 PM
From: Manuel Lopez-Mejia
Subject: Variable indexer size not allowed for a generic array (OPL)
Hi, I'm trying to create a utility function across a set of heterogeneous agents. To do this I created the following variables
float weight1[e in Employee][l in Location] = (l == Preference2[e]) ? 3 : 0 ;
float weight2[e in Employee][l in Location] = (l == Preference2[e]) ? 2 : 0 ;
float weight3[e in Employee][l in Location] = (l == Preference2[e]) ? 1 : 0 ;
float UtilWeight[e in Employee][l in Location] =
weight1[e][l] + weight2[e][l] + weight3[e][l];
However this produces the error code: model.mod: Variable indexer size not allowed for a generic array.
What is causing this to happen and how can it be remedied?
Here's a bigger snippet of the code and the datasets for further context. Thanks in advance!
------------------------------
Manuel Lopez-Mejia
------------------------------
#DecisionOptimization