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

Document how to run single cases #46

Closed
odow opened this issue Jan 20, 2024 · 1 comment
Closed

Document how to run single cases #46

odow opened this issue Jan 20, 2024 · 1 comment

Comments

@odow
Copy link
Collaborator

odow commented Jan 20, 2024

Load Julia in the variants/Project.toml

(base) oscar@Oscars-MBP rosetta-opf % julia --project=variants
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.0 (2023-12-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(variants) pkg> st
Status `~/Documents/lanl-ansi/rosetta-opf/variants/Project.toml`
  [7c4d4715] AmplNLWriter v1.2.0
  [2569d6c7] ConcreteStructs v0.2.3
  [992eb4ea] CondaPkg v0.2.22
  [b6b21f68] Ipopt v1.6.0
  [4076af6c] JuMP v1.18.1
  [309f4015] MathOptSymbolicAD v0.1.3
  [7f7a1694] Optimization v3.21.1
  [fd9f6733] OptimizationMOI v0.3.4
  [c36e90e8] PowerModels v0.20.1
  [6099a3de] PythonCall v0.9.15
  [37e2e3b7] ReverseDiff v1.15.1
⌃ [47a9eef4] SparseDiffTools v2.15.0
⌅ [9cc047cb] Ipopt_jll v300.1400.400+0
Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated`

julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 8 × Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores

julia> include("variants/optimization-cs-asrd.jl")

First call is to remove problem-independent compilation overhead:

julia> solve_opf("data/pglib_opf_case5_pjm.m")
[info | PowerModels]: extending matpower format with data: areas 1x3
[info | PowerModels]: removing 1 cost terms from generator 4: [4000.0, 0.0]
[info | PowerModels]: removing 1 cost terms from generator 1: [1400.0, 0.0]
[info | PowerModels]: removing 1 cost terms from generator 5: [1000.0, 0.0]
[info | PowerModels]: removing 1 cost terms from generator 2: [1500.0, 0.0]
[info | PowerModels]: removing 1 cost terms from generator 3: [3000.0, 0.0]
[info | PowerModels]: updated generator 4 cost function with order 2 to a function of order 3: [0.0, 4000.0, 0.0]
[info | PowerModels]: updated generator 1 cost function with order 2 to a function of order 3: [0.0, 1400.0, 0.0]
[info | PowerModels]: updated generator 5 cost function with order 2 to a function of order 3: [0.0, 1000.0, 0.0]
[info | PowerModels]: updated generator 2 cost function with order 2 to a function of order 3: [0.0, 1500.0, 0.0]
[info | PowerModels]: updated generator 3 cost function with order 2 to a function of order 3: [0.0, 3000.0, 0.0]

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit https://github.com/coin-or/Ipopt
******************************************************************************

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.:       36
Number of nonzeros in Lagrangian Hessian.............:      240

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...............:       18
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        6
        inequality constraints with only upper bounds:       12

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.3066346e+03 2.47e+00 1.01e+02  -1.0 2.78e+00    -  4.11e-03 3.82e-01h  1
   2  6.7182484e+03 2.36e+00 9.62e+01  -1.0 1.60e+01    -  7.37e-02 4.44e-02f  1
   3  6.6691211e+03 2.30e+00 9.34e+01  -1.0 1.30e+01    -  4.95e-01 2.40e-02f  1
   4  6.5744238e+03 2.04e+00 8.25e+01  -1.0 1.29e+01    -  3.67e-01 1.12e-01f  2
   5  6.8265929e+03 1.80e+00 7.10e+01  -1.0 1.23e+01    -  8.72e-01 1.20e-01h  2
   6  8.8541540e+03 1.08e+00 4.20e+01  -1.0 9.14e+00    -  5.92e-01 4.00e-01h  1
   7  1.0572759e+04 8.62e-01 3.58e+01  -1.0 2.94e+00    -  4.94e-01 2.00e-01h  1
   8  1.7308372e+04 3.63e-02 1.47e+01  -1.0 2.41e+00    -  7.66e-01 9.58e-01h  1
   9  1.7572883e+04 1.33e-02 1.10e+00  -1.0 2.11e+00    -  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.7590632e+04 1.69e-03 1.61e-01  -1.0 5.03e-01    -  1.00e+00 1.00e+00h  1
  11  1.7558725e+04 5.24e-03 5.03e-01  -2.5 6.03e-01    -  8.35e-01 9.36e-01f  1
  12  1.7553111e+04 3.34e-03 4.11e+00  -2.5 2.84e-01    -  1.00e+00 8.20e-01h  1
  13  1.7552956e+04 3.24e-05 1.26e-02  -2.5 6.35e-02    -  1.00e+00 1.00e+00h  1
  14  1.7551990e+04 1.35e-05 1.09e+00  -3.8 2.53e-02    -  1.00e+00 9.25e-01h  1
  15  1.7551938e+04 4.46e-08 1.23e-02  -3.8 7.00e-03    -  1.00e+00 1.00e+00f  1
  16  1.7551940e+04 2.36e-10 2.06e-04  -3.8 3.84e-04    -  1.00e+00 1.00e+00h  1
  17  1.7551892e+04 1.75e-07 2.11e-01  -5.7 2.49e-03    -  1.00e+00 9.68e-01f  1
  18  1.7551891e+04 6.82e-11 3.10e-05  -5.7 2.38e-04    -  1.00e+00 1.00e+00f  1
  19  1.7551891e+04 1.60e-14 6.53e-10  -5.7 5.20e-07    -  1.00e+00 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20  1.7551891e+04 6.34e-12 3.03e-07  -8.6 3.52e-05    -  1.00e+00 1.00e+00f  1
  21  1.7551891e+04 1.82e-14 2.21e-12  -8.6 3.34e-08    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 21

                                   (scaled)                 (unscaled)
Objective...............:   4.3879727096486897e+02    1.7551890838594758e+04
Dual infeasibility......:   2.2126691395576679e-12    8.8506765582306717e-11
Constraint violation....:   1.3544720900426910e-14    1.8207657603852567e-14
Variable bound violation:   2.9463905093507492e-08    2.9463905093507492e-08
Complementarity.........:   2.5059076302144483e-09    1.0023630520857793e-07
Overall NLP error.......:   2.5059076302144483e-09    1.0023630520857793e-07


Number of objective function evaluations             = 28
Number of objective gradient evaluations             = 22
Number of equality constraint evaluations            = 28
Number of inequality constraint evaluations          = 28
Number of equality constraint Jacobian evaluations   = 22
Number of inequality constraint Jacobian evaluations = 22
Number of Lagrangian Hessian evaluations             = 21
Total seconds in IPOPT                               = 2.576

EXIT: Optimal Solution Found.

Summary
   case........: data/pglib_opf_case5_pjm.m
   variables...: 44
   constraints.: 53
   feasible....: true
   cost........: 17552
   total time..: 32.540064096450806
     data time.: 8.220144987106323
     build time: 17.367176055908203
     solve time: 6.952743053436279

Dict{String, Any} with 9 entries:
  "cost"        => 17551.9
  "variables"   => 44
  "constraints" => 53
  "case"        => "data/pglib_opf_case5_pjm.m"
  "time_total"  => 32.5401
  "time_build"  => 17.3672
  "time_solve"  => 6.95274
  "time_data"   => 8.22014
  "feasible"    => true

Second call is that @ccoffrin reports as the time

julia> solve_opf("data/pglib_opf_case57_ieee.m")
[info | PowerModels]: removing 3 cost terms from generator 4: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 1: [1696.0624, 0.0]
[info | PowerModels]: removing 1 cost terms from generator 5: [3044.1037, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 2: Float64[]
[info | PowerModels]: removing 3 cost terms from generator 6: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 7: [3718.8979000000004, 0.0]
[info | PowerModels]: removing 1 cost terms from generator 3: [3407.5557000000003, 0.0]
[info | PowerModels]: updated generator 4 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 1 cost function with order 2 to a function of order 3: [0.0, 1696.0624, 0.0]
[info | PowerModels]: updated generator 5 cost function with order 2 to a function of order 3: [0.0, 3044.1037, 0.0]
[info | PowerModels]: updated generator 2 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 6 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]
[info | PowerModels]: updated generator 7 cost function with order 2 to a function of order 3: [0.0, 3718.8979000000004, 0.0]
[info | PowerModels]: updated generator 3 cost function with order 2 to a function of order 3: [0.0, 3407.5557000000003, 0.0]
This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:     1935
Number of nonzeros in inequality constraint Jacobian.:      480
Number of nonzeros in Lagrangian Hessian.............:     3167

Total number of variables............................:      445
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      388
                     variables with only upper bounds:        0
Total number of equality constraints.................:      435
Total number of inequality constraints...............:      240
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:       80
        inequality constraints with only upper bounds:      160

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  1.0503586e+02 3.76e+00 1.91e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  1.0716542e+04 2.65e+00 1.19e+02  -1.0 3.70e+00    -  2.74e-03 2.95e-01h  1
   2  1.3985380e+04 2.15e+00 9.71e+01  -1.0 7.02e+00    -  5.91e-02 1.90e-01h  1
   3  1.4674768e+04 2.08e+00 7.81e+01  -1.0 3.90e+00    -  3.67e-01 2.99e-02h  1
   4  2.0339343e+04 1.57e+00 5.90e+01  -1.0 4.22e+00    -  7.79e-01 2.46e-01h  1
   5  3.5192035e+04 2.16e-01 4.78e+01  -1.0 4.88e+00    -  7.60e-01 8.63e-01h  1
   6  3.6353626e+04 1.02e-01 2.36e+01  -1.0 1.06e+01    -  7.33e-01 5.28e-01h  1
   7  3.7555282e+04 1.23e-02 1.55e+00  -1.0 6.75e+00    -  1.00e+00 1.00e+00h  1
   8  3.7614438e+04 3.66e-04 1.89e-02  -1.0 1.26e+00    -  1.00e+00 1.00e+00h  1
   9  3.7591305e+04 4.39e-04 3.47e+00  -2.5 1.26e+00    -  8.64e-01 1.00e+00f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  3.7590573e+04 8.44e-05 2.30e+00  -2.5 1.37e-01    -  9.44e-01 8.36e-01h  1
  11  3.7590149e+04 1.43e-05 1.35e-03  -2.5 2.81e-02    -  1.00e+00 1.00e+00f  1
  12  3.7589396e+04 2.20e-06 1.91e-02  -3.8 4.24e-02    -  9.89e-01 1.00e+00h  1
  13  3.7589383e+04 8.08e-09 2.05e-06  -3.8 5.69e-04    -  1.00e+00 1.00e+00h  1
  14  3.7589339e+04 7.59e-09 1.23e-06  -5.7 2.32e-03    -  1.00e+00 1.00e+00h  1
  15  3.7589338e+04 1.85e-12 2.72e-10  -8.6 2.92e-05    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 15

                                   (scaled)                 (unscaled)
Objective...............:   1.0107655336327791e+03    3.7589338204193220e+04
Dual infeasibility......:   2.7159429322152497e-10    1.0100314467135135e-08
Constraint violation....:   1.8536838730653926e-12    1.8536838730653926e-12
Variable bound violation:   2.4448082225347889e-08    2.4448082225347889e-08
Complementarity.........:   2.6288234097387554e-09    9.7763258579482989e-08
Overall NLP error.......:   2.6288234097387554e-09    9.7763258579482989e-08


Number of objective function evaluations             = 16
Number of objective gradient evaluations             = 16
Number of equality constraint evaluations            = 16
Number of inequality constraint evaluations          = 16
Number of equality constraint Jacobian evaluations   = 16
Number of inequality constraint Jacobian evaluations = 16
Number of Lagrangian Hessian evaluations             = 15
Total seconds in IPOPT                               = 7.702

EXIT: Optimal Solution Found.

Summary
   case........: data/pglib_opf_case57_ieee.m
   variables...: 448
   constraints.: 675
   feasible....: true
   cost........: 37589
   total time..: 30.914313077926636
     data time.: 0.10789203643798828
     build time: 20.57877492904663
     solve time: 10.227646112442017

Dict{String, Any} with 9 entries:
  "cost"        => 37589.3
  "variables"   => 448
  "constraints" => 675
  "case"        => "data/pglib_opf_case57_ieee.m"
  "time_total"  => 30.9143
  "time_build"  => 20.5788
  "time_solve"  => 10.2276
  "time_data"   => 0.107892
  "feasible"    => true

Total time is 3.09+01 seconds, which is close to @ccoffrin's latest run of 3.25e+01, so a 2018 MacBook is a reasonable comparison for his hardware.

Profile

julia> using ProfileView

julia> @profview solve_opf("data/pglib_opf_case57_ieee.m")

Here's the profile: 2/3 of the time is spent building the problem:

image

@odow
Copy link
Collaborator Author

odow commented Jan 21, 2024

Closed by #49

@odow odow closed this as completed Jan 21, 2024
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

1 participant