Q:Is it possible too loop over elements of alist and use the values as indices?
- MSI株式会社
- 2022年5月13日
- 読了時間: 1分
更新日:2022年6月7日
Q: Is it possible too loop over elements of alist and use the values as indices?
Example:
A[0..29] = inFile.readInt();
x <- list(30);
// some constraints for x
result <- sum[i in x](A[i]);
maximize result;
A:Yes, you can do this using
In your example, you canwrite:
A[0..29] = inFile.readInt();
x <- list(30);
// some constraints for x
result <- sum(x, i => A[i]);
maximize result;
A good use case of
lambda functions can be
found for instance
in the CVRPproblem
Komentarze