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

Simulation gets stuck during profiling in Linux #1183

Open
joaquimg opened this issue Dec 9, 2024 · 3 comments
Open

Simulation gets stuck during profiling in Linux #1183

joaquimg opened this issue Dec 9, 2024 · 3 comments
Assignees
Labels

Comments

@joaquimg
Copy link

joaquimg commented Dec 9, 2024

Simulation gets stuck during profiling in Linux.

The linux fail happens consistently in CI (see jump-dev/open-energy-modeling-benchmarks#36 (comment)) and in my WSL virtual machine.

On Windows, things run smoothly.

MWE:

# necessary sienna stack
import PowerSystems
import PowerSimulations
import HydroPowerSimulations
import PowerSystemCaseBuilder
# solver
import JuMP
import HiGHS
# julia base
import Dates
import Logging
# profile
import Profile

# Profile.init() # default fails
# @show Profile.init(n = 10^6, delay = 0.001) #fails
# @show Profile.init(n = 10^6, delay = 0.1) # works

function build_and_solve(problem)
    PowerSimulations.build!(
        problem;
        output_dir = mktempdir(),
        console_level = Logging.Info,
    )
    PowerSimulations.solve!(problem; console_level = Logging.Info)
    return
end

function main()

    # case data is downloaded from a julia artifcat
    sys = PowerSystemCaseBuilder.build_system(
        PowerSystemCaseBuilder.PSISystems,
        "modified_RTS_GMLC_DA_sys",
    )

    template_uc = PowerSimulations.ProblemTemplate()

    PowerSimulations.set_device_model!(
        template_uc,
        PowerSystems.Line,
        PowerSimulations.StaticBranch,
    )
    PowerSimulations.set_device_model!(
        template_uc,
        PowerSystems.Transformer2W,
        PowerSimulations.StaticBranch,
    )
    PowerSimulations.set_device_model!(
        template_uc,
        PowerSystems.TapTransformer,
        PowerSimulations.StaticBranch,
    )

    PowerSimulations.set_device_model!(
        template_uc,
        PowerSystems.ThermalStandard,
        PowerSimulations.ThermalStandardUnitCommitment,
    )
    PowerSimulations.set_device_model!(
        template_uc,
        PowerSystems.RenewableDispatch,
        PowerSimulations.RenewableFullDispatch,
    )
    PowerSimulations.set_device_model!(
        template_uc,
        PowerSystems.PowerLoad,
        PowerSimulations.StaticPowerLoad,
    )
    PowerSimulations.set_device_model!(
        template_uc,
        PowerSystems.HydroDispatch,
        HydroPowerSimulations.HydroDispatchRunOfRiver,
    )
    PowerSimulations.set_device_model!(
        template_uc,
        PowerSystems.RenewableNonDispatch,
        PowerSimulations.FixedOutput,
    )

    PowerSimulations.set_service_model!(
        template_uc,
        PowerSystems.VariableReserve{PowerSystems.ReserveUp},
        PowerSimulations.RangeReserve,
    )
    PowerSimulations.set_service_model!(
        template_uc,
        PowerSystems.VariableReserve{PowerSystems.ReserveDown},
        PowerSimulations.RangeReserve,
    )

    solver =
        JuMP.optimizer_with_attributes(HiGHS.Optimizer, "mip_rel_gap" => 0.5)

    PowerSimulations.set_network_model!(
        template_uc,
        PowerSimulations.NetworkModel(PowerSimulations.CopperPlatePowerModel),
    )

    problem = PowerSimulations.DecisionModel(
        template_uc,
        sys;
        optimizer = solver,
        horizon = Dates.Hour(12),
        initial_time = Dates.DateTime("2020-01-01T00:00:00") +
                       Dates.Hour((29 - 1) * 24),
        optimizer_solve_log_print = true,
    )

    @show 1
    # precompile
    build_and_solve(problem)
    @show 2
    Profile.@profile build_and_solve(problem) # stuck here
    @show 3

    return
end

main()

see: jump-dev/open-energy-modeling-benchmarks#36 (comment)

@jd-lara
Copy link
Member

jd-lara commented Dec 11, 2024

@joaquimg I will make a new release of the packages and re-test

@jd-lara
Copy link
Member

jd-lara commented Dec 26, 2024

@joaquimg you should test this again with PowerSimulations @v0.29.1

@joaquimg
Copy link
Author

joaquimg commented Jan 7, 2025

The issue persists even on latest versions:

  [08572546] FlameGraphs v1.0.1
  [87dc4568] HiGHS v1.13.0
  [fc1677e0] HydroPowerSimulations v0.10.0
  [682c06a0] JSON v0.21.4
  [4076af6c] JuMP v1.23.6
  [e690365d] PowerSimulations v0.29.1
  [f00506e0] PowerSystemCaseBuilder v1.3.10
  [bcd98974] PowerSystems v4.4.1
  [ade2ca70] Dates
  [56ddb016] Logging
  [ea8e919c] SHA v0.7.0

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

No branches or pull requests

3 participants