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

Tests on M1 and Other Platforms #827

Closed
kevin-kruse opened this issue Jun 1, 2022 · 8 comments
Closed

Tests on M1 and Other Platforms #827

kevin-kruse opened this issue Jun 1, 2022 · 8 comments

Comments

@kevin-kruse
Copy link

Hi,

I'm trying to execute a simple OPF using PandaPower in combination with PowerModels. For this, I'm using the 118-bus test network (case118() in pandapower), as follows:

import pandapower.networks as nw
import pandapower as pp


net = nw.case118()

# runs the powermodels.jl switch optimization
pp.runpm_ac_opf(net)

However, I always obtain the following error:

OPF did not converge!
Traceback (most recent call last):
  File "/Users/kevin/Git/playground_x64/main.py", line 11, in <module>
    pp.runpm_ac_opf(net)
  File "/Users/kevin/Git/playground_x64/venv/lib/python3.8/site-packages/pandapower/runpm.py", line 134, in runpm_ac_opf
    _runpm(net, delete_buffer_file=delete_buffer_file, pm_file_path=pm_file_path, pdm_dev_mode=pdm_dev_mode)
  File "/Users/kevin/Git/playground_x64/venv/lib/python3.8/site-packages/pandapower/opf/run_powermodels.py", line 36, in _runpm
    read_pm_results_to_net(net, ppc, ppci, result_pm)
  File "/Users/kevin/Git/playground_x64/venv/lib/python3.8/site-packages/pandapower/converter/powermodels/from_pm.py", line 30, in read_pm_results_to_net
    raise OPFNotConverged("PowerModels.jl OPF not converged")
pandapower.optimal_powerflow.OPFNotConverged: PowerModels.jl OPF not converged

Is there something I oversee that this does not happen?

I've run the PowerModels test and received the following result:

conic solver: Test Failed at /Users/kevin/.julia/packages/PowerModels/saEFf/test/opf-obj.jl:19
  Expression: result["termination_status"] == OPTIMAL
   Evaluated: MathOptInterface.ALMOST_OPTIMAL == MathOptInterface.OPTIMAL
Stacktrace:
 [1] top-level scope at /Users/kevin/.julia/packages/PowerModels/saEFf/test/opf-obj.jl:19
 [2] top-level scope at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1119
 [3] top-level scope at /Users/kevin/.julia/packages/PowerModels/saEFf/test/opf-obj.jl:17
 [4] top-level scope at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1119
 [5] top-level scope at /Users/kevin/.julia/packages/PowerModels/saEFf/test/opf-obj.jl:4
(...)
Test Summary:                                      | Pass  Fail  Total
 linear objective                                  |    4     1      5
    nlp solver                                     |    2            2
    conic solver                                   |    1     1      2
    lp solver                                      |    1            1

Is this error related to the error above?
I'm using PyCharm (x64-edition) in combination with Julia on a MacBook M1.

Best,
Kevin

@ccoffrin
Copy link
Member

ccoffrin commented Jun 2, 2022

I can't comment on why PandaPower might be failing or not. I would imagine that if you try to solve an AC-OPF problem with a bunch of switches in it, it may not converge. This is an open research topic. AC-OTS in PowerModels is fairly well tested and it seems to be fairly reliable with the Juniper solver for example. Testing with the DC or SOCWR models are good tools for debugging model feasibility issues.

As for the tests in PowerModels, these should be passing with the latest versions the Julia packages. So you might start my resolving that by updating to the latest version of Julia, JuMP and the solver packages.

@kevin-kruse
Copy link
Author

kevin-kruse commented Aug 19, 2022

Hi @ccoffrin,

sorry for the late answer - I moved forward with my own implementation.
But I'm still curious, why PowerModels does not pass all tests on my M1 Mac Installation.

So far, these are my findings:

  • PowerModels passes all tests on my Windows 11 (ARM-based) virtual machine with the x64-Julia installation

(Before each try, I deleted all Julia installations and the ~/.julia folder, and as of this website (https://lanl-ansi.github.io/PowerModels.jl/stable/), I only install PowerModels and Ipopt)

  • Using the newest version (1.8.0 release) and the x64/Intel version, I get 6 errors, all of the following "shape" (meaning it looks just like a meaningless rounding-error, but still curious why this happens)
5-bus case, finite_differencing: Test Failed at /Users/kevin/.julia/packages/PowerModels/kU7PK/test/pf-native.jl:451
  Expression: isapprox(bus_qg_nlp[i], bus_qg_nls[i]; atol = 1.0e-6)
   Evaluated: isapprox(0.29181671142578125, 0.2918197309440912; atol = 1.0e-6)
  • Using the newest version (1.8.0 release) and the M1-native ARM version, I get the two following, more serious looking errors:
5-bus case: Test Failed at /Users/kevin/.julia/packages/PowerModels/kU7PK/test/am.jl:45
  Expression: isapprox(LinearAlgebra.det(sm.matrix), 0.0)
   Evaluated: isapprox(-3.7169769389394446e-7, 0.0)
Stacktrace:
 [1] macro expansion
   @ /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/Test/src/Test.jl:464 [inlined]
 [2] macro expansion
   @ ~/.julia/packages/PowerModels/kU7PK/test/am.jl:45 [inlined]
 [3] macro expansion
   @ /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/Test/src/Test.jl:1357 [inlined]
 [4] macro expansion
   @ ~/.julia/packages/PowerModels/kU7PK/test/am.jl:40 [inlined]
 [5] macro expansion
   @ /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/Test/src/Test.jl:1357 [inlined]
 [6] top-level scope
   @ ~/.julia/packages/PowerModels/kU7PK/test/am.jl:39
5-bus ext case: Test Failed at /Users/kevin/.julia/packages/PowerModels/kU7PK/test/am.jl:53
  Expression: isapprox(LinearAlgebra.det(sm.matrix), 0.0)
   Evaluated: isapprox(-2.4913226095600544e-8, 0.0)
  • Using the LTS Version (as used on GitHub Actions) - 1.6.7 namely - in the x64/Intel version, I obtain the same errors as with the newest x64/Intel version:
5-bus case, finite_differencing: Test Failed at /Users/kevin/.julia/packages/PowerModels/kU7PK/test/pf-native.jl:451
  Expression: isapprox(bus_qg_nlp[i], bus_qg_nls[i]; atol = 1.0e-6)
   Evaluated: isapprox(0.29181671142578125, 0.2918197309440912; atol = 1.0e-6)
  • Using the newest version (1.8.0 release) in the x64/Intel version, and installing the newest PowerModels (add PowerModels#master instead of add PowerModels), the error also remain:
5-bus case, finite_differencing: Test Failed at /Users/kevin/.julia/packages/PowerModels/zWSSf/test/pf-native.jl:451
  Expression: isapprox(bus_qg_nlp[i], bus_qg_nls[i]; atol = 1.0e-6)
   Evaluated: isapprox(0.29181671142578125, 0.2918197309440912; atol = 1.0e-6)

Is this issue known and (probably) an error on my side or of the PowerModels package?

@ccoffrin ccoffrin changed the title PowerModels OPF does not converge Test on M1 Aug 19, 2022
@ccoffrin
Copy link
Member

Ok thanks! I just got access to an M1 system, so I'll check if I can reproduce.

@ccoffrin ccoffrin reopened this Aug 19, 2022
@ccoffrin
Copy link
Member

I confirmed all PM tests pass on Julia v1.8, OSX with an Intel CPU. Will check M1 soon.

@odow this thread may be of interest, stay tuned.

@odow
Copy link
Collaborator

odow commented Aug 19, 2022 via email

@ccoffrin ccoffrin changed the title Test on M1 Tests on M1 and Other Platforms Aug 20, 2022
@ccoffrin
Copy link
Member

@kevin-kruse I was able to reproduce your reported issue on M1 (see #839), all things considered, it is a pretty minor issue with the numerical precision of Julia's built in library.

For the other platforms I have not yet been able to reproduce any of the errors you mention. In some rare occasions while doing package development I have had issues where the wrong jll was being used for the tests that I was running and it would results in a few minor numerical errors.

We will try to get to the bottom of this on all platform combinations, but based on what you have shown, I would not be concerned that the software is not working correctly. It looks more like only very minor differences that arise from the details of floating point arithmetic in different platforms.

@kevin-kruse
Copy link
Author

kevin-kruse commented Aug 22, 2022

Hi @ccoffrin,

okay, the ARM-version passes now all tests on my M1, thx!
Just to clarify the errors regarding the platforms: I'm always using my M1 mac, but different platform versions of Julia (running through Rosetta vs. native version) - but yeah these are also minor numerical errors.

Best,
Kevin

@ccoffrin
Copy link
Member

I've been using an M1 Mac with PowerModels for nearly a year now with no notable issues, so closing this.

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

3 participants