CPLEX OPL 返回具有条件的集合索引

CPLEX OPL Returning a set index with a condition

我有一个如下所示的元组,我想 return 第一个元素的 TimePeriodID,其 ActivePeriod 值为 "YES"。尝试使用 first 和 minl & ord 函数,但没有用。任何帮助将非常感激。谢谢

tuple timeperiod {
  string TimePeriodID;
  string TimePeriodName;
  float CurrencyRate;
  float Rank;
  string ActivePeriod;
}
{timeperiod} TimePeriods = ...;
tuple timeperiod {
  string TimePeriodID;
  string TimePeriodName;
  float CurrencyRate;
  float Rank;
  string ActivePeriod;
}
{timeperiod} TimePeriods = {<"A","B",1.0,2.3,"NO">,<"V","B",4.0,2.3,"YES">,<"D","B",4.0,2.3,"YES">};

string answer=first({i | i in TimePeriods : i.ActivePeriod=="YES"}).TimePeriodID;

execute
{
writeln(answer);
}

给予

V