Objective function declaration issue

If I have a member of an objective function:
sum((setup_cost[f,p,j]*PR[f,p,j,t]+oper_cost[p,j]*PRD[o,f,p,j,t]) for o in O,f in FAM, p in PROD[f], j in U, t in TIME)
and I want to limit the counter o, f and p on 1…end-1 (in arrays), how can I do this?
Thanks!
marco

It’s easier to help if you provide a minimal working example. Take a read of the first post in PSA: make it easier to help you.

Presumably, you want something like

@objective(
    model, 
    Min,
    sum(
        setup_cost[f, p, j] * PR[f, p, j, t] + 
        oper_cost[p, j] * PRD[o, f, p, j, t]
        for o in O[1:end-1]
        for f in FAM[1:end-1]
        for p in PROD[f][1:end-1]
        for j in U
        for t in TIME
    )
)

Thanks odow, so “end” is also valid operator, not only length(array)?

so “end” is also valid operator,

Yes. Here is the documentation for Julia arrays: https://docs.julialang.org/en/v1/manual/arrays/#man-array-indexing-1

1 Like

Thanks odow.

1 Like