# How to read the @objective command?

**URL:** <https://discourse.julialang.org/t/how-to-read-the-objective-command/30752>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [November 5, 2019, 3:20pm UTC](https://discourse.julialang.org/t/how-to-read-the-objective-command/30752 "2019-11-05T15:20:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaquelSantos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raquelsantos/32/3668_2.png) [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Post date:** [November 5, 2019, 3:20pm UTC](https://discourse.julialang.org/t/how-to-read-the-objective-command/30752/1 "2019-11-05T15:20:11Z")

</div>

```julia
@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

---

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [November 5, 2019, 3:48pm UTC](https://discourse.julialang.org/t/how-to-read-the-objective-command/30752/2 "2019-11-05T15:48:44Z")

</div>

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:

```julia
@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.

---

<div class="post-metadata">

**Author:** ![RaquelSantos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raquelsantos/32/3668_2.png) [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Post date:** [November 5, 2019, 3:56pm UTC](https://discourse.julialang.org/t/how-to-read-the-objective-command/30752/4 "2019-11-05T15:56:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [November 5, 2019, 3:57pm UTC](https://discourse.julialang.org/t/how-to-read-the-objective-command/30752/5 "2019-11-05T15:57:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [November 5, 2019, 3:59pm UTC](https://discourse.julialang.org/t/how-to-read-the-objective-command/30752/6 "2019-11-05T15:59:25Z")

</div>

There are some examples here: [Multi-dimensional Arrays · The Julia Language](https://docs.julialang.org/en/v1/manual/arrays/#Generator-Expressions-1)

---

<div class="post-metadata">

**Author:** ![RaquelSantos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raquelsantos/32/3668_2.png) [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Post date:** [November 5, 2019, 5:33pm UTC](https://discourse.julialang.org/t/how-to-read-the-objective-command/30752/8 "2019-11-05T17:33:30Z")

</div>

Thanks!!! 😃
