Skip to content

(WIP) Test script sIPOPT #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 109 commits into
base: master
Choose a base branch
from
Open

(WIP) Test script sIPOPT #1

wants to merge 109 commits into from

Conversation

andrewrosemberg
Copy link
Owner

@andrewrosemberg andrewrosemberg commented Jun 28, 2024

Based on sIPOPT paper https://optimization-online.org/wp-content/uploads/2011/04/3008.pdf.

EQ (23 -24).

Order of sensitivities:

  1. primal variables
  2. slacks of inequalities
  3. duals of all constraints
  4. duals of lower bounds (LB) of primal variables with LB
  5. duals of LB of slacks of GEQ constraints
  6. duals of upper bounds (UB) of primal variables with UB
  7. duals of UPB of slacks of LEQ constraints

M Matrix

M = 
[
 [W A' -I I];
 [A 0 0 0];
 [V_L 0 (X - X_L) 0]
 [V_U 0 0 0 (X_U - X)]
]

Notice that given some variables and slacks don't have lower or upper bound (or neither), we have:

  • -I: A matrix of minus ones and zeros that has the number of rows equal to the number of standard primal variables (# primal variables + # slack), and the number of columns is just the number of the subset that has lower bounds. The inverse of V_L.
  • Similar logic is for I and V_U but for the upper bound.

@andrewrosemberg andrewrosemberg self-assigned this Jun 28, 2024
@andrewrosemberg
Copy link
Owner Author

andrewrosemberg commented Jun 28, 2024

I am trying to figure out how to ask MOI to ignore the fact that parameters are parameters and just treat them as variables in the calculation of the eval_hessian_lagrangian and eval_constraint_jacobian.

I.e., I want to, after solving the problem and getting the primal-dual solution from the optimizer, basically ignore the parameter constraints, p ∈ MathOptInterface.Parameter{Float64}(1.0), when I query the hessian and jacobian. Ideally without modifying the original model.

From what I understand, the problem is this IF:

If variable is a parameter, return zero


# Parameters
@variable(model, p ∈ MOI.Parameter(1.0))
@variable(model, p2 ∈ MOI.Parameter(2.0))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not p == 1.0 instead to use the MOI.EqualTo set?

@andrewrosemberg
Copy link
Owner Author

andrewrosemberg commented Jul 1, 2024

For the algorithm, we considering the optimization::
image

With kkt:
image

So that we can calculate the following matrix:
image

Where:
The primal variables are stacked:
image
and the duals of of the bounds as well: image

  1. This means I have to build the hessian of the Lagrangian (W = \nabla_xx L) and the jacobian of the constraints (A = \nabla_x c) for the standard model considering auxiliary slack variables in the vector of primal variables, right?

  2. If so, is it easily doable in JuMP/MOI?

  3. Am I being an idiot and getting the hessian and jacobian considering the slacks is a trivial transformation?

I believe I am being an idiot, the jacobian for the slacks is just the identity matrix and for the hessian is zero.

@Robbybp
Copy link

Robbybp commented Jul 2, 2024

This means I have to build the hessian of the Lagrangian (W = \nabla_xx L) and the jacobian of the constraints (A = \nabla_x c) for the standard model considering auxiliary slack variables in the vector of primal variables, right?

I don't think you need to consider slacks. You should be able to do everything in the space of the original problem, aside from any variables/constraints you might need to add to handle parameters.

nlp_utilities.jl Outdated
Comment on lines 181 to 183
for (i, con) in enumerate(cons[ineq_locations])
bound_duals[num_vars+i] = dual.(con)
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you're using JuMP's inequality multipliers for both the slack bound multipliers and the slack equality multipliers (in the Hessian). I believe this is correct, up to potentially a sign change.

So as long as it's well-tested, I have no problem with using the slack reformulation, although I would personally find it simpler to just use the original problem's primal variables and inequality constraints.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is almost done, I think I will use the reformulation, test it, and then change to using the original problem (but now knowing my tests make sense).

Copy link

@Robbybp Robbybp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on parameters vs. fixed variables.

Comment on lines 14 to 16
@variable(model, p ∈ MOI.Parameter(1.0))
@variable(model, p2 ∈ MOI.Parameter(2.0))
@variable(model, p3 ∈ MOI.Parameter(100.0))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not that familiar with variable in Parameter declarations. This seems similar to declaring the variable then calling fix(p, value), with the following differences:

  • We use FixRef and is_fixed for the fixed variable and ParameterRef and is_parameter for the parameter variable
  • The dual can be obtained for a FixRef constraint, but not for a ParameterRef constraint.
  • set_parameter_value and parameter_value can be used to set and get a parameter's value, regardless of whether the model has been modified since a solve.

Any other differences I should be aware of?

Copy link
Owner Author

@andrewrosemberg andrewrosemberg Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joaquimg might have more knowledge on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants