I have a model with many nonlinear expressions and I would like to evaluate these to test my model.
For example I have something like this
m = Model()
#What is T(x=2)?
I’m writing an MCP model using the Complementarity package and a really useful model debugging technique is to evaluate the equations (NLexpressions in this case) at a solution point.
Any advice would be greatly appreciated.
value(v -> Dict(x => 2.0)[v], T)
The first argument takes a JuMP variable name, and returns a value. So essentially the
Dict can contain several variables and other ways are legit, as long as they return a value.
I had the arguments in the value backwards.
Thank you so much.
Actually, you are right, they are flipped. Had to jump to source to figure this out.
We try to follow the Julia style guide: Style Guide · The Julia Language
It suggests that functions should always come as the first argument. The main reason is to allow the
do syntax like:
value(T) do v
return v == x ? 2.0 : 0.0