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

Improve performance #139

Open
ocots opened this issue Jun 7, 2023 · 9 comments
Open

Improve performance #139

ocots opened this issue Jun 7, 2023 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@ocots
Copy link
Member

ocots commented Jun 7, 2023

@PierreMartinon @BaptisteCbl your mission if you accept it is to improve drastically the performance of our solver, thanks to wise profiling and benchmarking.

@BaptisteCbl
Copy link
Collaborator

BaptisteCbl commented Jun 8, 2023

For now we have this kind of results:
Results are on classic goddard, with a grid of size 30.
JUMP resolution

Solving...
This is Ipopt version 3.14.13, running with linear solver MUMPS 5.6.0.

Number of nonzeros in equality constraint Jacobian...:      573
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:     1710

Total number of variables............................:      125
                     variables with only lower bounds:       32
                variables with lower and upper bounds:       93
                     variables with only upper bounds:        0
Total number of equality constraints.................:       93
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  1.0100000e+00 3.96e-01 1.42e-01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  1.0099579e+00 3.82e-01 1.55e+01  -1.7 4.61e-01    -  1.04e-02 3.59e-02f  1
   2  1.0123693e+00 9.05e-03 3.60e+03  -1.7 4.80e-01    -  5.61e-02 9.90e-01f  1
   3  1.0089467e+00 6.48e-03 2.52e+03  -1.7 1.30e-01    -  6.51e-01 2.87e-01h  1
   4  1.0012838e+00 2.56e-03 2.85e+02  -1.7 2.80e-01    -  9.15e-01 9.90e-01h  1
   5  1.0055718e+00 6.94e-04 7.38e+04  -1.7 2.99e-01    -  6.99e-01 9.90e-01f  1
   6  1.0072751e+00 2.21e-03 1.25e+06  -1.7 2.56e-01    -  2.70e-01 1.00e+00f  1
   7  1.0072253e+00 1.23e-03 2.25e+05  -1.7 2.87e-01    -  8.86e-01 1.00e+00h  1
   8  1.0067740e+00 2.09e-04 6.58e-01  -1.7 1.00e-01    -  1.00e+00 1.00e+00h  1
   9  1.0067862e+00 1.61e-07 9.53e+02  -3.8 3.16e-03    -  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.0087743e+00 5.46e-04 1.44e-01  -3.8 1.36e-01    -  1.00e+00 1.00e+00h  1
  11  1.0086566e+00 4.36e-05 4.27e-04  -3.8 9.79e-02    -  1.00e+00 1.00e+00h  1
  12  1.0102082e+00 2.49e-04 2.57e+03  -5.7 1.12e-01    -  8.27e-01 1.00e+00h  1
  13  1.0119095e+00 4.94e-04 3.83e+02  -5.7 1.51e-01    -  8.51e-01 7.35e-01h  1
  14  1.0122542e+00 2.19e-04 2.17e+01  -5.7 1.81e-01    -  9.43e-01 6.00e-01h  1
  15  1.0124547e+00 1.52e-04 1.27e-03  -5.7 2.00e-01    -  1.00e+00 1.00e+00f  1
  16  1.0124458e+00 5.21e-06 9.77e-05  -5.7 7.70e-02    -  1.00e+00 1.00e+00h  1
  17  1.0124460e+00 1.31e-07 7.94e-07  -5.7 1.13e-02    -  1.00e+00 1.00e+00h  1
  18  1.0125075e+00 1.19e-05 1.17e+01  -8.6 1.00e-01    -  8.33e-01 7.69e-01h  1
  19  1.0125219e+00 1.25e-05 6.03e+00  -8.6 1.67e-01    -  8.53e-01 7.51e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20  1.0125259e+00 6.81e-06 1.38e+00  -8.6 9.08e-02    -  1.00e+00 8.70e-01h  1
  21  1.0125263e+00 3.46e-07 7.65e-06  -8.6 4.05e-02    -  1.00e+00 1.00e+00f  1
  22  1.0125262e+00 3.43e-08 6.14e-07  -8.6 1.33e-02    -  1.00e+00 1.00e+00h  1
  23  1.0125262e+00 2.18e-09 4.54e-08  -8.6 3.39e-03    -  1.00e+00 1.00e+00h  1
  24  1.0125262e+00 1.87e-11 4.19e-10  -8.6 3.07e-04    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 24

                                   (scaled)                 (unscaled)
Objective...............:  -1.0125262367726526e+00    1.0125262367726526e+00
Dual infeasibility......:   4.1912912891737240e-10    4.1912912891737240e-10
Constraint violation....:   1.8681001190401503e-11    1.8681001190401503e-11
Variable bound violation:   1.4092401593955658e-37    1.4092401593955658e-37
Complementarity.........:   2.5080751303192126e-09    2.5080751303192126e-09
Overall NLP error.......:   2.5080751303192126e-09    2.5080751303192126e-09


Number of objective function evaluations             = 25
Number of objective gradient evaluations             = 25
Number of equality constraint evaluations            = 25
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 25
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 24
Total seconds in IPOPT                               = 0.057

EXIT: Optimal Solution Found.
Local solution found
Objective value = 1.0125262367726526

JUMP -> MathOptNLPModel NLPModelsIpopt resolution

This is Ipopt version 3.14.13, running with linear solver MUMPS 5.6.0.

Number of nonzeros in equality constraint Jacobian...:      573
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:     1710

Total number of variables............................:      125
                     variables with only lower bounds:       32
                variables with lower and upper bounds:       93
                     variables with only upper bounds:        0
Total number of equality constraints.................:       93
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  1.0100000e+00 3.96e-01 1.42e-01   0.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  1.0130396e+00 9.59e-03 1.15e+04  -1.4 4.74e-01    -  1.09e-02 9.90e-01f  1
   2  1.0122507e+00 9.02e-03 1.08e+04  -1.3 5.04e-02   2.0 1.00e+00 5.95e-02h  1
   3  1.0072459e+00 5.60e-03 6.41e+03  -1.7 7.41e-02   1.5 1.00e+00 3.98e-01h  1
   4  1.0067482e+00 5.08e-03 1.22e+04  -1.1 1.30e+00    -  6.31e-01 9.28e-02h  1
   5  1.0025563e+00 1.69e-03 1.73e+03  -1.9 1.63e-01    -  8.09e-01 8.49e-01h  1
   6  1.0027663e+00 8.58e-05 2.26e+02  -7.7 4.12e-02    -  3.64e-01 9.79e-01h  1
   7  1.0027961e+00 9.25e-07 7.40e+01  -3.8 5.79e-03    -  9.10e-01 9.92e-01h  1
   8  1.0028949e+00 5.73e-07 7.99e+02  -5.0 9.87e-03    -  9.53e-01 1.00e+00h  1
   9  1.0071683e+00 7.52e-04 1.02e+03  -4.6 2.65e-01    -  4.03e-01 8.63e-01f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  1.0099600e+00 1.07e-03 9.53e+02  -4.6 3.54e-01    -  2.49e-01 5.26e-01h  1
  11  1.0107794e+00 1.17e-03 8.81e+02  -4.2 1.08e+00    -  3.84e-01 4.66e-01h  1
  12  1.0095781e+00 1.33e-03 9.59e+03  -3.8 2.14e+00    -  1.00e+00 2.49e-01h  1
  13  1.0104206e+00 1.31e-04 5.81e-03  -4.5 1.07e-01    -  1.00e+00 1.00e+00h  1
  14  1.0118314e+00 4.06e-04 3.81e+02  -5.0 1.83e-01    -  1.00e+00 8.03e-01h  1
  15  1.0122730e+00 1.40e-04 2.32e-03  -5.2 1.17e-01    -  1.00e+00 1.00e+00h  1
  16  1.0124602e+00 1.01e-04 1.59e-03  -5.8 1.45e-01    -  1.00e+00 1.00e+00h  1
  17  1.0125015e+00 2.16e-05 3.68e-04  -6.2 1.10e-01    -  1.00e+00 1.00e+00h  1
  18  1.0125225e+00 1.79e-05 2.49e-04  -7.0 1.56e-01    -  1.00e+00 1.00e+00h  1
  19  1.0125258e+00 6.06e-06 6.12e-03  -7.8 8.63e-02    -  1.00e+00 9.99e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20  1.0125263e+00 3.13e-07 6.75e-06  -8.6 3.89e-02    -  1.00e+00 1.00e+00h  1
  21  1.0125263e+00 6.22e-08 1.07e-06  -9.6 1.74e-02    -  1.00e+00 1.00e+00h  1
  22  1.0125263e+00 7.47e-09 1.64e-07 -11.2 6.34e-03    -  1.00e+00 1.00e+00h  1
  23  1.0125263e+00 3.67e-10 8.95e-09 -11.8 1.36e-03    -  1.00e+00 1.00e+00h  1
  24  1.0125263e+00 1.32e-12 1.79e-10 -12.1 8.11e-05    -  1.00e+00 1.00e+00h  1
  25  1.0125263e+00 3.05e-16 1.04e-11 -12.3 1.30e-06    -  1.00e+00 1.00e+00h  1
  26  1.0125263e+00 2.22e-16 1.44e-11 -12.3 6.90e-09    -  1.00e+00 1.00e+00h  1
  27  1.0125263e+00 2.22e-16 1.35e-13 -12.3 4.61e-10    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 27

                                   (scaled)                 (unscaled)
Objective...............:  -1.0125263397980653e+00    1.0125263397980653e+00
Dual infeasibility......:   1.3533594327169007e-13    1.3533594327169007e-13
Constraint violation....:   2.2204460492503131e-16    2.2204460492503131e-16
Variable bound violation:   9.9162263955676622e-09    9.9162263955676622e-09
Complementarity.........:   5.0227126311592196e-13    5.0227126311592196e-13
Overall NLP error.......:   5.0227126311592196e-13    5.0227126311592196e-13


Number of objective function evaluations             = 28
Number of objective gradient evaluations             = 28
Number of equality constraint evaluations            = 28
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 28
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 27
Total seconds in IPOPT                               = 0.068

EXIT: Optimal Solution Found.

CTDirect OCPModel -> ADNLPModel (v0.5) NLPModelsIpopt resolution

This is Ipopt version 3.14.13, running with linear solver MUMPS 5.6.0.

Number of nonzeros in equality constraint Jacobian...:      574
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:     7875

Total number of variables............................:      125
                     variables with only lower bounds:       31
                variables with lower and upper bounds:       62
                     variables with only upper bounds:        0
Total number of equality constraints.................:       94
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0 -1.0100000e+00 9.00e-01 2.00e+00   0.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1 -1.0030260e+00 7.00e-01 2.48e+02  -0.7 9.00e-01    -  4.85e-03 2.22e-01f  1
   2 -1.0093386e+00 1.84e-01 1.18e+02  -0.7 7.00e-01   2.0 9.97e-01 7.37e-01h  1
   3 -1.0096326e+00 1.07e-01 1.22e+02  -0.4 3.59e-01   1.5 1.00e+00 4.17e-01h  1
   4 -1.0084386e+00 1.07e-03 2.97e+01  -0.6 3.26e-01    -  8.12e-01 9.90e-01h  1
   5 -1.0080173e+00 8.40e-05 1.77e+01  -2.2 5.92e-02    -  9.57e-01 9.90e-01h  1
   6 -1.0080420e+00 1.73e-07 2.79e+00  -7.7 2.19e-03    -  9.85e-01 9.98e-01h  1
   7 -1.0097714e+00 1.37e-04 3.07e+02  -4.7 7.07e-02    -  7.89e-01 1.00e+00f  1
   8 -1.0124338e+00 9.26e-04 6.15e+00  -4.7 2.00e-01    -  1.00e+00 9.84e-01h  1
   9 -1.0123613e+00 1.24e-04 4.87e-03  -5.3 1.13e-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.0124870e+00 7.79e-05 4.60e+00  -5.9 1.25e-01    -  1.00e+00 9.86e-01h  1
  11 -1.0125120e+00 1.97e-05 5.85e-01  -6.3 1.20e-01    -  1.00e+00 9.93e-01h  1
  12 -1.0125239e+00 1.49e-05 2.24e-01  -7.1 1.52e-01    -  1.00e+00 9.94e-01h  1
  13 -1.0125262e+00 5.03e-06 1.80e-05  -8.1 8.24e-02    -  1.00e+00 1.00e+00h  1
  14 -1.0125262e+00 3.29e-07 8.64e-05  -8.4 3.54e-02    -  1.00e+00 1.00e+00h  1
  15 -1.0125263e+00 5.03e-08 5.30e-07 -10.0 1.66e-02    -  1.00e+00 1.00e+00h  1
  16 -1.0125263e+00 6.43e-09 8.25e-08 -11.0 5.87e-03    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 16

                                   (scaled)                 (unscaled)
Objective...............:  -1.0125263394411863e+00   -1.0125263394411863e+00
Dual infeasibility......:   8.2471633469491931e-08    8.2471633469491931e-08
Constraint violation....:   1.8099726162290608e-09    6.4261801435705479e-09
Variable bound violation:   8.3128719602365564e-09    8.3128719602365564e-09
Complementarity.........:   6.6254607323767334e-10    6.6254607323767334e-10
Overall NLP error.......:   1.8099726162290608e-09    8.2471633469491931e-08


Number of objective function evaluations             = 17
Number of objective gradient evaluations             = 17
Number of equality constraint evaluations            = 17
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 17
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 16
Total seconds in IPOPT                               = 3.009

EXIT: Optimal Solution Found.

CTDirect OCPModel -> ADNLPModel (v0.6) NLPModelsIpopt resolution

This is Ipopt version 3.14.13, running with linear solver MUMPS 5.6.0.

Number of nonzeros in equality constraint Jacobian...:      574
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:      341

Total number of variables............................:      125
                     variables with only lower bounds:       31
                variables with lower and upper bounds:       62
                     variables with only upper bounds:        0
Total number of equality constraints.................:       94
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0 -1.0100000e+00 9.00e-01 2.00e+00   0.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1 -1.0030260e+00 7.00e-01 2.48e+02  -0.7 9.00e-01    -  4.85e-03 2.22e-01f  1
   2 -1.0093386e+00 1.84e-01 1.18e+02  -0.7 7.00e-01   2.0 9.97e-01 7.37e-01h  1
   3 -1.0096326e+00 1.07e-01 1.22e+02  -0.4 3.59e-01   1.5 1.00e+00 4.17e-01h  1
   4 -1.0084386e+00 1.07e-03 2.97e+01  -0.6 3.26e-01    -  8.12e-01 9.90e-01h  1
   5 -1.0080173e+00 8.40e-05 1.77e+01  -2.2 5.92e-02    -  9.57e-01 9.90e-01h  1
   6 -1.0080420e+00 1.73e-07 2.79e+00  -7.7 2.19e-03    -  9.85e-01 9.98e-01h  1
   7 -1.0097714e+00 1.37e-04 3.07e+02  -4.7 7.07e-02    -  7.89e-01 1.00e+00f  1
   8 -1.0124338e+00 9.26e-04 6.15e+00  -4.7 2.00e-01    -  1.00e+00 9.84e-01h  1
   9 -1.0123613e+00 1.24e-04 4.87e-03  -5.3 1.13e-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.0124870e+00 7.79e-05 4.60e+00  -5.9 1.25e-01    -  1.00e+00 9.86e-01h  1
  11 -1.0125120e+00 1.97e-05 5.85e-01  -6.3 1.20e-01    -  1.00e+00 9.93e-01h  1
  12 -1.0125239e+00 1.49e-05 2.24e-01  -7.1 1.52e-01    -  1.00e+00 9.94e-01h  1
  13 -1.0125262e+00 5.03e-06 1.80e-05  -8.1 8.24e-02    -  1.00e+00 1.00e+00h  1
  14 -1.0125262e+00 3.28e-07 1.04e-06  -8.4 3.53e-02    -  1.00e+00 1.00e+00h  1
  15 -1.0125263e+00 5.01e-08 5.29e-07  -9.9 1.66e-02    -  1.00e+00 1.00e+00h  1
  16 -1.0125263e+00 6.48e-09 8.31e-08 -11.7 5.91e-03    -  1.00e+00 1.00e+00h  1
  17 -1.0125263e+00 2.83e-10 3.33e-09 -12.3 1.20e-03    -  1.00e+00 1.00e+00h  1
  18 -1.0125263e+00 7.57e-13 8.43e-12 -12.3 6.11e-05    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 18

                                   (scaled)                 (unscaled)
Objective...............:  -1.0125263392620425e+00   -1.0125263392620425e+00
Dual infeasibility......:   8.4322266966417110e-12    8.4322266966417110e-12
Constraint violation....:   1.5765166949677223e-13    7.5696393597723964e-13
Variable bound violation:   9.9161631406108341e-09    9.9161631406108341e-09
Complementarity.........:   5.9181867333975404e-13    5.9181867333975404e-13
Overall NLP error.......:   5.9181867333975404e-13    8.4322266966417110e-12


Number of objective function evaluations             = 19
Number of objective gradient evaluations             = 19
Number of equality constraint evaluations            = 19
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 19
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 18
Total seconds in IPOPT                               = 8.586

EXIT: Optimal Solution Found.

To have these results I used the code in : https://github.com/BaptisteCbl/JumpVSADNLP

@ocots
Copy link
Member Author

ocots commented Jun 12, 2023

A bench:

using BenchmarkTools

function test_alloc_good()

    function get_view(Y, i, n_slice, N)
        return @view Y[i:i+n_slice-1]
    end

    function set!(Z, i, n_slice, N, z)
        Z[i:i+n_slice-1] = z
    end

    function core_for!(v, x, z, n)
        (v[i] = 2x[i]+3z[i] for i  1:n)
    end

    n_slice = 50
    n_disc  = 2000
    N = n_slice * n_disc
    Y = rand(N)
    Z = zeros(N)
    x = zeros(n_slice)
    v = zeros(n_slice)

    for i  1:n_disc

        #
        z = get_view(Y, i, n_slice, N)

        #
        core_for!(v, x, z, n_slice)
        set!(Z, i, n_slice, N, v)

        #
        x[:] = z

    end

    #
    nothing

end

function test_alloc_bad()

    function get(Y, i, n_slice, N)
        return Y[i:i+n_slice-1]
    end

    function set!(Z, i, n_slice, N, z)
        Z[i:i+n_slice-1] = z[:]
    end

    function core(x, z)
        return 2x[:]+3z[:]
    end

    #function core_for(x, z, n)
    #    return [2x[i]+3z[i] for i ∈ 1:n]
    #end

    #function core_for!(v, x, z, n)
    #    v[:] = [2x[i]+3z[i] for i ∈ 1:n]
    #end

    n_slice = 50
    n_disc  = 2000
    N = n_slice * n_disc
    Y = rand(N)
    Z = zeros(N)
    x = zeros(n_slice)
    v = zeros(n_slice)

    for i  1:n_disc

        #
        z = get(Y, i, n_slice, N)

        #
        set!(Z, i, n_slice, N, core(x[:], z[:]))

        #
        x = z

    end

    #
    nothing

end

println("Allocations and times for good and bad code")
println()

println("good code")
t_good = @benchmark test_alloc_good()
display(t_good)

println()
println("bad code")
t_bad = @benchmark test_alloc_bad()
display(t_bad)

println()
# print the ratio of the times
println("ratio of times: ", mean(t_bad.times)/mean(t_good.times))
println("ratio of allocations: ", mean(t_bad.memory)/mean(t_good.memory))

Results:

Allocations and times for good and bad code

good code
BenchmarkTools.Trial: 3534 samples with 1 evaluation.
 Range (min  max):  332.106 μs  84.731 ms  ┊ GC (min  max):  0.00%  73.71%
 Time  (median):       1.050 ms              ┊ GC (median):     0.00%
 Time  (mean ± σ):     1.398 ms ±  2.073 ms  ┊ GC (mean ± σ):  13.85% ± 13.54%

  ▇▂  ▅█▅▄▃▂▁▁     ▁▁                                          ▁
  ███▆████████▇▇█▇█████▆▆▇▅▅▅▆▄▅▅▁▄▅▃▅▄▅▄▇▆▆▅▃▆▇▃▅▃▄▅▅▅▅▅▆▅▅▃▅ █
  332 μs        Histogram: log(frequency) by time      8.57 ms <

 Memory estimate: 1.53 MiB, allocs estimate: 6.

bad code
BenchmarkTools.Trial: 1699 samples with 1 evaluation.
 Range (min  max):  1.623 ms  81.262 ms  ┊ GC (min  max):  0.00%   0.00%
 Time  (median):     1.993 ms              ┊ GC (median):     0.00%
 Time  (mean ± σ):   2.916 ms ±  3.547 ms  ┊ GC (mean ± σ):  12.48% ± 17.07%

  █▅▄▃▂▂▃▃▂▃▃▂▂▁ ▁                                            
  ████████████████████▇▇▇▆▆▅▆▇▅▃▅▃▆▃▆▅▅▄▅▄▁▄▄▃▄▁▁▁▁▃▄▁▁▄▁▁▁▅ █
  1.62 ms      Histogram: log(frequency) by time     11.9 ms <

 Memory estimate: 10.04 MiB, allocs estimate: 18006.

ratio of times: 2.0862225595372297
ratio of allocations: 6.5762081784386615

@ocots
Copy link
Member Author

ocots commented Jun 12, 2023

@jbcaillau @PierreMartinon @BaptisteCbl @joseph-gergaud

nlp_constraints from CTBase must be updated: https://github.com/control-toolbox/CTBase.jl/blob/bench/bench/bench_nlp_constraints.md

The code: https://github.com/control-toolbox/CTBase.jl/blob/bench/bench/bench_nlp_constraints.jl

@ocots
Copy link
Member Author

ocots commented Jul 4, 2024

Too old.

@ocots ocots closed this as completed Jul 4, 2024
@jbcaillau jbcaillau reopened this Jul 4, 2024
@jbcaillau
Copy link
Member

jbcaillau commented Jul 4, 2024

@ocots @BaptisteCbl @amontoison well, take a look 🙂

  • 10x speed up wrt to last year version
  • 4x to 5x difference with pure JuMP code

At this price, more than acceptable decrease in performance... and no RK scheme to hard (hand) code.

NB. Tested with ma57 instead of MUMPS.

Method = (:direct, :adnlp, :ipopt)
This is Ipopt version 3.14.14, running with linear solver ma57.

Number of nonzeros in equality constraint Jacobian...:      634
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:      341

Total number of variables............................:      125
                     variables with only lower bounds:       31
                variables with lower and upper bounds:       62
                     variables with only upper bounds:        0
Total number of equality constraints.................:       94
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0 -1.0100000e+00 9.00e-01 2.00e+00   0.0 0.00e+00    -  0.00e+00 0.00e+00   0
Reallocating memory for MA57: lfact (8303)
   1 -1.0030260e+00 7.00e-01 2.48e+02  -0.7 9.00e-01    -  4.85e-03 2.22e-01f  1
   2 -1.0093386e+00 1.84e-01 1.18e+02  -0.7 7.00e-01   2.0 9.97e-01 7.37e-01h  1
   3 -1.0096326e+00 1.07e-01 1.22e+02  -0.4 3.59e-01   1.5 1.00e+00 4.17e-01h  1
   4 -1.0084386e+00 1.07e-03 2.97e+01  -0.6 3.26e-01    -  8.12e-01 9.90e-01h  1
   5 -1.0080173e+00 8.40e-05 1.77e+01  -2.2 5.92e-02    -  9.57e-01 9.90e-01h  1
   6 -1.0080420e+00 1.73e-07 2.79e+00  -7.7 2.19e-03    -  9.85e-01 9.98e-01h  1
   7 -1.0097714e+00 1.37e-04 3.07e+02  -4.7 7.07e-02    -  7.89e-01 1.00e+00f  1
   8 -1.0124338e+00 9.26e-04 6.15e+00  -4.7 2.00e-01    -  1.00e+00 9.84e-01h  1
   9 -1.0123613e+00 1.24e-04 4.87e-03  -5.3 1.13e-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.0124870e+00 7.79e-05 4.60e+00  -5.9 1.25e-01    -  1.00e+00 9.86e-01h  1
  11 -1.0125120e+00 1.97e-05 5.85e-01  -6.3 1.20e-01    -  1.00e+00 9.93e-01h  1
  12 -1.0125239e+00 1.49e-05 2.24e-01  -7.1 1.52e-01    -  1.00e+00 9.94e-01h  1
  13 -1.0125262e+00 5.03e-06 1.80e-05  -8.1 8.24e-02    -  1.00e+00 1.00e+00h  1
  14 -1.0125262e+00 3.29e-07 8.64e-05  -8.4 3.54e-02    -  1.00e+00 1.00e+00h  1
  15 -1.0125263e+00 5.03e-08 5.30e-07 -10.0 1.66e-02    -  1.00e+00 1.00e+00h  1
  16 -1.0125263e+00 6.43e-09 8.25e-08 -11.0 5.87e-03    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 16

                                   (scaled)                 (unscaled)
Objective...............:  -1.0125263394411863e+00   -1.0125263394411863e+00
Dual infeasibility......:   8.2471633885825539e-08    8.2471633885825539e-08
Constraint violation....:   1.8099727272513633e-09    6.4261801574483357e-09
Variable bound violation:   8.3128719602365564e-09    8.3128719602365564e-09
Complementarity.........:   6.6254607323533790e-10    6.6254607323533790e-10
Overall NLP error.......:   1.8099727272513633e-09    8.2471633885825539e-08


Number of objective function evaluations             = 17
Number of objective gradient evaluations             = 17
Number of equality constraint evaluations            = 17
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 17
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 16
Total seconds in IPOPT                               = 0.230

EXIT: Optimal Solution Found.
BenchmarkTools.Trial: 19 samples with 1 evaluation.
 Range (min  max):  233.690 ms  614.121 ms  ┊ GC (min  max): 0.00%  55.63%
 Time  (median):     243.806 ms               ┊ GC (median):    1.65%
 Time  (mean ± σ):   267.470 ms ±  84.652 ms  ┊ GC (mean ± σ):  7.51% ± 12.59%

   █                                                             
  ▇█▄▆▆▄▄▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄ ▁
  234 ms           Histogram: frequency by time          614 ms <

 Memory estimate: 38.34 MiB, allocs estimate: 373614.

@PierreMartinon
Copy link
Member

PierreMartinon commented Jul 5, 2024

Necrothread :D
Still, this is nice. We should add somewhere in the doc the steps to install HSL properly.

@jbcaillau
Copy link
Member

jbcaillau commented Jul 23, 2024

@ocots @PierreMartinon Can also try to use StaticArrays.jl, most probably in CTFlows.jl as CTDirect.jl are probably too large (size <= 100). Check JuliaArrays/StaticArrays.jl#506

@ocots
Copy link
Member Author

ocots commented Jul 23, 2024

Should be used by the user when calling a flow I guess.

@ocots ocots added the enhancement New feature or request label Jul 26, 2024
@jbcaillau
Copy link
Member

Related matter: control-toolbox/CTBenchmarks.jl#25

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

No branches or pull requests

4 participants