Skip to content

Parameters with initial NaN values seem to poison the model #104

Description

@rdeits

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions