Creating a model with parameters whose initial values are NaN seems to break the model, even if those parameters are changed to non-NaN before any call to solve!. For example:
# Set up the model
m = Model(OSQP.Optimizer())
# Create an externally-controlled value. This is initially NaN, but
# we will set it to non-NaN later
outer_value = Ref(NaN)
# Create a parameter which just reads from our outer value
param = Parameter(m) do
outer_value[]
end
# Constrain that the variable x == param. At this point, outer_value[] == NaN
x = Variable(m)
@constraint m x == param
# Fix our outer_value so that it is non-NaN
outer_value[] = 1.0
# Solve. All the parameters are now non-NaN, but the solver still fails:
solve!(m)
objectivevalue(m)
gives an objective value of NaN.
Moving the outer_value[] = 1.0 to before the call to @constraint fixes the problem, but shouldn't be necessary as far as I know.
Creating a model with parameters whose initial values are
NaNseems to break the model, even if those parameters are changed to non-NaN before any call tosolve!. For example:gives an objective value of
NaN.Moving the
outer_value[] = 1.0to before the call to@constraintfixes the problem, but shouldn't be necessary as far as I know.