Hi, I’m new to both Julia and JuMP. Experience in C#, Scala and I like functional programming. Would love some help to get in to Julia optimisation.

How do I compose functions or expressions in JuMP? I can make a trivial example that works for a one-variable problem as follows, with the expressions to compose in the middle. It’s the step after that where I get stuck.

```
using JuMP, Clp
m = Model(Clp.Optimizer)
# Data
sourceMass_t = 1000.0
sourceGold_g = 600.0
# Fraction of each component taken
@variable(m, 0.0 <= f <= 1.0)
# Expressions to compose
@expression(m, mass_t, f * sourceMass_t)
@expression(m, gold_g, f * sourceGold_g)
@expression(m, cost_USD, 15.0 * mass_t)
@expression(m, recGold_TrOz, 0.90 / 31.1 * gold_g)
@expression(m, rev_USD, 1800 * recGold_TrOz)
# Net value objective
@objective(m, Max, rev_USD - cost_USD)
# Only constraint
con = @constraint(m, mass_t <= 700)
optimize!(m)
```

The next step to make that slightly more interesting is to have multiple data records, so data becomes something like:

```
sourceMass_t = [1000.0, 1500.0, 2000.0]
sourceGold_g = [600.0, 700.0, 900.0]
```

and objective and constraint change to become sums:

```
con = @constraint(m, sum(mass_t) <= 2200)
@objective(m, Max, sum(rev_USD) - sum(cost_USD))
```

The piece I’m missing is the ability to use the expressions composed already and apply to each pair of `sourceMass_t`

and `sourceGold_g`

. i.e. a JuMP-friendly `map`

function, where each pair is given an associated `f`

variable, `rev_USD`

and `cost_USD`

. In pseudocode:

```
map(the_composed_expressions, zip_of_sourceMass_t_and_source_Gold_g)
```

I don’t believe I should need to rewrite all the expressions to accept arrays of variables and manually iterate over them; the function graph doesn’t change.

The goal after that would be to have many many more functions to compose and many more `f`

fractions at different decision points, so I’m interested in the general approach here. Thanks.