Skip to content
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

Symbolic AD Sensitivity to Init Values #143

Closed
ccoffrin opened this issue Jun 19, 2022 · 4 comments
Closed

Symbolic AD Sensitivity to Init Values #143

ccoffrin opened this issue Jun 19, 2022 · 4 comments

Comments

@ccoffrin
Copy link

Tested with,

  [01bcebdf] Nonconvex v2.0.3
  [bf347577] NonconvexIpopt v0.4.0

On this commit of rosetta-opf, https://github.com/lanl-ansi/rosetta-opf/tree/103972f32e8a04e01e7abb0647143a68edd7f597

This is the Ipopt trace of running Nonconvex as it is in that commit of rosetta-opf,

This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:      155
Number of nonzeros in inequality constraint Jacobian.:       48
Number of nonzeros in Lagrangian Hessian.............:       63

Total number of variables............................:       44
                     variables with only lower bounds:        0
                variables with lower and upper bounds:       39
                     variables with only upper bounds:        0
Total number of equality constraints.................:       35
Total number of inequality constraints...............:       24
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:       24

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  1.0054400e+04 6.00e+00 1.81e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  8.0025517e+03 5.52e+00 1.68e+01  -1.0 2.19e+01    -  7.44e-02 7.99e-02f  1
   2  7.9141416e+03 5.30e+00 9.87e+00  -1.0 1.16e+01    -  1.78e-01 3.96e-02f  1
   3  7.6950085e+03 4.11e+00 1.43e+01  -1.0 1.18e+01    -  3.72e-01 2.24e-01f  1
   4  8.6648629e+03 3.28e+00 1.10e+01  -1.0 8.94e+00    -  3.10e-01 2.03e-01h  1
   5  9.7062709e+03 2.89e+00 9.63e+00  -1.0 4.89e+00    -  1.14e-01 1.18e-01h  1
   6  1.7640660e+04 1.28e-01 2.47e+01  -1.0 4.14e+00    -  7.03e-01 1.00e+00h  1
   7  1.7564716e+04 4.08e-02 4.09e+01  -1.0 3.92e+00    -  8.55e-01 8.84e-01h  1
   8  1.7583466e+04 3.73e-03 4.13e-01  -1.0 1.46e+00    -  1.00e+00 1.00e+00h  1
   9  1.7561018e+04 3.42e-03 9.34e-02  -1.7 5.19e-01    -  1.00e+00 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  1.7553052e+04 4.68e-03 1.58e+00  -2.5 2.04e-01    -  1.00e+00 8.46e-01h  1
  11  1.7552865e+04 3.82e-05 1.44e-01  -2.5 6.03e-02    -  1.00e+00 1.00e+00h  1
  12  1.7552853e+04 2.37e-06 4.11e-03  -2.5 2.25e-03    -  1.00e+00 1.00e+00h  1
  13  1.7551979e+04 5.36e-06 1.01e+00  -3.8 2.38e-02    -  1.00e+00 9.30e-01f  1
  14  1.7551938e+04 1.14e-07 1.16e-02  -3.8 6.57e-03    -  1.00e+00 1.00e+00f  1
  15  1.7551940e+04 1.53e-10 1.62e-04  -3.8 3.30e-04    -  1.00e+00 1.00e+00h  1
  16  1.7551892e+04 1.75e-07 2.10e-01  -5.7 2.49e-03    -  1.00e+00 9.68e-01f  1
  17  1.7551891e+04 6.79e-11 3.08e-05  -5.7 2.38e-04    -  1.00e+00 1.00e+00f  1
  18  1.7551891e+04 1.97e-14 6.45e-10  -5.7 5.16e-07    -  1.00e+00 1.00e+00h  1
  19  1.7551891e+04 6.26e-12 3.03e-07  -8.6 3.52e-05    -  1.00e+00 1.00e+00f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20  1.7551891e+04 5.53e-14 3.30e-12  -8.6 3.33e-08    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 20

                                   (scaled)                 (unscaled)
Objective...............:   4.3879727248486819e+02    1.7551890899394726e+04
Dual infeasibility......:   3.3004878996206002e-12    1.3201951598482401e-10
Constraint violation....:   3.5738878523261518e-14    5.5289106626332796e-14
Variable bound violation:   2.9463905093507492e-08    2.9463905093507492e-08
Complementarity.........:   2.5059076126551939e-09    1.0023630450620775e-07
Overall NLP error.......:   2.5059076126551939e-09    1.0023630450620775e-07


Number of objective function evaluations             = 21
Number of objective gradient evaluations             = 21
Number of equality constraint evaluations            = 21
Number of inequality constraint evaluations          = 21
Number of equality constraint Jacobian evaluations   = 21
Number of inequality constraint Jacobian evaluations = 21
Number of Lagrangian Hessian evaluations             = 20
Total seconds in IPOPT                               = 3.838

EXIT: Optimal Solution Found.

Update the variable declaration lines like so, where init on most of them is updated from 1.0 to 0.0. This is the standard initial point for rosetta-opf models.

    for (i,bus) in ref[:bus]
        addvar!(model, "va_$(i)", -Inf, Inf, init=0.0) #va
        addvar!(model, "vm_$(i)", bus["vmin"], bus["vmax"], init=1.0) #vm
    end

    for (i,gen) in ref[:gen]
        addvar!(model, "pg_$(i)", gen["pmin"], gen["pmax"], init=0.0) #pg
        addvar!(model, "qg_$(i)", gen["qmin"], gen["qmax"], init=0.0) #qg
    end

    for (l,i,j) in ref[:arcs]
        branch = ref[:branch][l]
        addvar!(model, "p_$(l)_$(i)_$(j)", -branch["rate_a"], branch["rate_a"], init=0.0) #p
        addvar!(model, "q_$(l)_$(i)_$(j)", -branch["rate_a"], branch["rate_a"], init=0.0) #q
    end

This is start of the Ipopt trace (trimmed for brevity). It does not converge.

This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:      155
Number of nonzeros in inequality constraint Jacobian.:       24
Number of nonzeros in Lagrangian Hessian.............:       63

Total number of variables............................:       44
                     variables with only lower bounds:        0
                variables with lower and upper bounds:       39
                     variables with only upper bounds:        0
Total number of equality constraints.................:       35
Total number of inequality constraints...............:       24
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:       24

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  1.0059989e+02 3.99e+00 2.88e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  8.1360018e+03 2.48e+00 1.02e+02  -1.0 2.83e+00    -  4.01e-03 3.78e-01h  1
   2  7.9369274e+03 2.47e+00 1.01e+02  -1.0 1.65e+01    -  7.27e-02 5.27e-03f  4
   3  7.8504933e+03 2.46e+00 1.01e+02  -1.0 1.53e+01    -  2.06e-01 2.49e-03f  5
   4  7.8449025e+03 2.46e+00 9.97e+01  -1.0 1.10e+01    -  4.14e-01 5.14e-04f  9
   5  7.8433361e+03 2.46e+00 9.83e+01  -1.0 9.39e+00    -  5.78e-01 4.97e-04h 10
   6  8.0060483e+03 1.52e+00 6.09e+01  -1.0 8.05e+00    -  3.81e-01 3.81e-01s 21
   7  9.0498708e+03 1.05e+00 4.21e+01  -1.0 6.03e+00    -  3.09e-01 3.09e-01s 21
   8  9.2703900e+03 1.02e+00 4.09e+01  -1.0 7.01e+00    -  2.81e-02 2.81e-02s 21
   9  1.1280436e+04 7.75e-01 3.10e+01  -1.0 6.92e+00    -  2.42e-01 2.42e-01s 21
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  1.3381839e+04 5.18e-01 2.07e+01  -1.0 4.71e+00    -  3.32e-01 3.32e-01s 21
  11  1.6855352e+04 3.77e-01 4.77e+01  -1.0 2.60e+00    -  8.24e-01 0.00e+00S 21
  12  1.7108637e+04 3.91e-01 3.52e+01  -1.0 6.37e-01    -  1.00e+00 3.46e-01h  1
  13  1.7111054e+04 3.91e-01 2.67e+02  -1.0 5.92e-01    -  1.00e+00 5.10e-03h  1
  14r 1.7111054e+04 3.91e-01 9.99e+02  -0.3 0.00e+00    -  0.00e+00 4.01e-07R  8
  15r 1.7163967e+04 3.91e-01 9.98e+02  -0.3 4.70e+02    -  2.28e-02 9.91e-04f  1
  16r 1.7163967e+04 3.91e-01 9.99e+02  -0.4 0.00e+00    -  0.00e+00 4.34e-07R  8
  17r 1.7251932e+04 3.89e-01 9.97e+02  -0.4 6.35e+01    -  5.47e-02 1.68e-03f  1
  18r 1.7596031e+04 3.61e-01 9.45e+02  -0.4 1.06e+00    -  1.93e-01 5.26e-02f  1
  19r 1.7990337e+04 1.27e-01 7.05e+02  -0.4 4.12e-01    -  2.07e-01 2.54e-01f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20r 1.8066128e+04 1.03e-01 3.45e+02  -0.4 2.57e-01    -  1.00e+00 5.11e-01f  1
  21r 1.8066830e+04 1.03e-01 5.89e+02  -0.4 4.32e-01    -  2.09e-01 8.57e-03f  1
  22r 1.8149913e+04 7.86e-02 2.66e+03  -0.4 4.33e-01    -  3.56e-03 1.00e+00f  1
  23r 1.8150057e+04 7.85e-02 2.24e+03  -0.4 5.63e-01   4.0 1.76e-01 1.76e-01f  1
  24r 1.8152403e+04 7.67e-02 1.44e+03  -0.4 4.31e-01   3.5 4.80e-02 1.00e+00h  1
  25  1.8117753e+04 1.01e-01 2.43e+04  -1.0 1.89e+00    -  1.65e-01 5.40e-03f  1
  26  1.8117686e+04 1.01e-01 1.65e+08  -1.0 3.79e+00    -  2.75e-01 4.14e-05h  1
  27  1.8117686e+04 1.01e-01 1.61e+14  -1.0 2.13e+00    -  4.08e-01 4.14e-07h  1
  28r 1.8117686e+04 1.01e-01 1.00e+03  -1.0 0.00e+00    -  0.00e+00 2.07e-09R  2
  29r 1.8117902e+04 1.01e-01 9.96e+02  -1.0 1.02e+01    -  9.21e-01 3.12e-03f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  30r 1.8877840e+04 3.89e-04 9.10e+01  -1.0 2.76e-01    -  6.72e-01 9.09e-01f  1
  31r 1.8879591e+04 3.22e-04 7.49e+01  -1.0 7.10e-01    -  2.29e-01 1.73e-01f  1
  32r 1.8879610e+04 3.21e-04 9.10e+02  -1.0 5.70e-01    -  8.30e-01 2.09e-03f  1
  33r 1.8879837e+04 3.13e-04 3.01e+02  -1.0 5.69e-01    -  2.00e-04 2.43e-02f  1
  34r 1.8894954e+04 3.37e-07 5.53e+01  -1.0 5.53e-01   2.0 8.90e-01 1.00e+00f  1
  35  1.8858800e+04 7.27e-07 9.71e+01  -1.0 1.05e+01    -  1.18e-01 9.36e-04f  6
  36  1.8841027e+04 1.05e-06 9.36e+01  -1.0 3.52e+00    -  3.45e-01 1.29e-03f  7
  37  1.8832091e+04 1.24e-06 9.46e+01  -1.0 1.44e+00    -  8.62e-01 2.37e-03f  8
  38  1.8085066e+04 1.21e-01 4.94e+01  -1.0 9.48e-01    -  1.00e+00 4.96e-01F  1
  39  1.8064725e+04 1.32e-01 5.22e+01  -1.0 5.02e-01    -  1.00e+00 3.75e-02f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  40  1.8064542e+04 1.32e-01 5.21e+01  -1.0 4.68e-01    -  3.56e-04 3.56e-04s 11
  41r 1.8064542e+04 1.32e-01 9.99e+02  -0.7 0.00e+00    -  0.00e+00 0.00e+00R  1
  42r 1.8064593e+04 1.32e-01 9.98e+02  -0.7 1.95e+02    -  9.78e-01 9.91e-04f  1
  43r 1.8064593e+04 1.32e-01 9.99e+02  -0.9 0.00e+00    -  0.00e+00 3.19e-07R  7
  44r 1.8066277e+04 1.31e-01 9.97e+02  -0.9 2.24e+01    -  8.64e-01 2.57e-03f  1
  45r 1.9065219e+04 5.04e-03 1.32e+02  -0.9 2.79e-01    -  9.95e-01 8.68e-01f  1
  46r 1.9068675e+04 4.16e-03 1.09e+02  -0.9 7.57e-01    -  1.85e-01 1.76e-01f  1
  47r 1.9068711e+04 4.15e-03 8.77e+02  -0.9 6.53e-01    -  9.49e-01 2.14e-03f  1
  48r 1.9069183e+04 4.04e-03 3.68e+02  -0.9 6.52e-01    -  2.22e-04 2.77e-02f  1
  49r 1.9089962e+04 1.53e-06 6.38e+01  -0.9 6.38e-01   2.0 4.89e-01 1.00e+00f  1
...
@mohamed82008
Copy link
Member

I will look into it. Thanks for the report.

@mohamed82008
Copy link
Member

I think this is fixed in NonconvexIpopt 0.4.1 JuliaRegistries/General#62664.

@mohamed82008
Copy link
Member

There are also more perf improvements possible now that I am depending on NonconvexUtils in NonconvexIpopt. So the timings can be slashed significantly in future versions. I will close this issue now.

@ccoffrin
Copy link
Author

I also confirm this appears to be fixed in NonconvexIpopt v0.4.1

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

No branches or pull requests

2 participants