MethodError: no method matching -(::VariableRef, ::Nothing)

Take a read of the first post in Please read: make it easier to help you.

It’s easier to help if you can provide a minimal working example that demonstrates the problem.

The main reason is that your function lookup is returning nothing. However, the bigger issue is that you cannot use functions like this in a JuMP model. In particular, you are passing the variable sn[1, t], not the value of the variable.

You will need to formulate the problem as a mixed integer linear program.

1 Like