Range constraint

Looking closer, it seems you are also not passing the variables C and x, and are passing constraint_gen to itself! You need to put all the variables you need to use in function signature and then pass those variables when you call the function. So if you define the function constraint_gen(lb,ub,::Range) then you only have access to those variables inside the function (except if they are global variables, which it’s best to avoid), and you need to pass them all when you call the function.

Maybe the docs on functions might be helpful?

1 Like