JuMP diet tutorial issue?

Hi!

I’m following the JuMP documentation’s Diet problem code, and I’m running into a constraint error (“ERROR: At code.jl:66: @constraint(model, row.min <= sum(foods[!, row.nutrient] .* foods.x) <= row.max): Unrecognized constraint building format…This is due to specifying an unrecognized function, constraint set, and/or extra positional/keyword arguments.”)

on this bit of code:

@constraint(
model,
[row in eachrow(limits)],
row.min <= sum(foods[!, row.nutrient] .* foods.x) <= row.max,
);

Can someone pretty please help me figure out what’s going wrong?

You forgot to copy paste this part of the tutorial:

limits.max = coalesce.(limits.max, Inf)

This makes the missing in limits cause an error when you try to build the constraint. In general it’s easier to download the entire file via the link Download the source as a .jl file at the top of the tutorial, this gives you a well-formatted error-free file to work upon.

1 Like