# Decision Optimization

View Only

## Need help in understanding OPL syntax #### Amey JoshiMon July 27, 2020 11:21 AM • #### 1.  Need help in understanding OPL syntax

Posted Mon July 27, 2020 11:21 AM
The OPL documentation at the location
IDE and OPL > Optimization Programming Language (OPL) > Language User's Manual > Introduction to OPL > A short tour of OPL > Constraint programming: an inventory matching problem
describes a solution to an inventory problem called 'steelmill'.

The solution to the problem expresses the constraint that a slab can be used to make coils of at most two colours as
```forall(s in 1..nbSlabs) colorCt: sum (c in 1..nbColors) (or(o in 1..nbOrders : colors[o] == c) (where[o] == s)) <= 2; ```

I am finding it hard to understand this syntax, especially the portion `(or(o in 1..nbOrders : colors[o] == c) (where[o] == s))`
The `or` function, I thought, returns 1 if the order has colour 'c'. The portion`(where[o] == s)`selects an order that is used the slab b.  But what does the juxtaposition of the two predicates mean?

<main role="main">
</main>

------------------------------
Amey Joshi
------------------------------

#DecisionOptimization

• #### 2.  RE: Need help in understanding OPL syntax

Posted Mon July 27, 2020 11:41 AM
The term `o in 1..nbOrders : colors[o] == c` yields all the orders that have color `c`. So `or(...)` iterates over all orders that have color `c`. For each of these orders `o` it checks whether `where[o] == s`. It finally forms the logical OR of all these tests. So the whole OR evaluates to true if there is at least one order of color `c` that has `where` equal to `s`.

------------------------------
Daniel Junglas
------------------------------