How to read the @objective command?

@objective (m,Min,sum (LS [i, j]*C[i, j] for i, j ∈ 1:f))

How to make this expression read the for i,j. The way I did the error appears:

syntax: invalid iteration specification

You shouldn’t have spaces between a function name and the parenthesis or between the variable name and the bracket. I would have expected an ERROR: syntax: space before "[" not allowed type of message instead of the iteration message, but I would fix those and see if that gets you there or closer.

Like this:

@objective (m,Min, sum(LS[i, j]*C[i, j] for i, j ∈ 1:f))

EDIT: Also, you have two loop variables (i, j), but are iterating only over one dimension, that’s the source of the iteration error.

I removed the spaces, thanks.
I’m learning how to code, I don’t know how I can iterate two loop variables.

Learning is great! That’s why I’m here too. Keep asking questions.


There are some examples here:

1 Like

Thanks!!! :smiley: