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

UPD: JuMP v1.15 #459

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

UPD: JuMP v1.15 #459

wants to merge 6 commits into from

Conversation

pseudocubic
Copy link
Collaborator

Updates to support JuMP v1.15 nonlinear syntax.

@odow @ccoffrin We had to make some strange changes to the expressions and constraints in order to fix the failing tests from #454. In particular, if you look at something like any of the constraint_mc_power_balance functions, we had to put a negative sign inside the sum calls. By applying this to power or current variables we were able to get tests to pass. See for example line 151 in acp.jl or line 288 in objective.jl.

Any ideas on why this works? We want to hold off on merging if we can until we have a grasp on the reason behind this.

CC @juanjospina

pg = var(pm, n, :pg, i)
pg = isa(pg, JuMP.Containers.DenseAxisArray) ? pg.data : pg

int_dim = length(pg)
if length(gen["cost"]) == 1
gen_cost[(n,i)] = gen["cost"][1]
elseif length(gen["cost"]) == 2
gen_cost[(n,i)] = JuMP.@NLexpression(pm.model, gen["cost"][1]*sum(pg[i] for i in 1:int_dim) + gen["cost"][2])
gen_cost[(n,i)] = JuMP.@expression(pm.model, (-gen["cost"][1]*sum(-pg[i] for i in 1:int_dim)) + gen["cost"][2])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really not be needed. Let me take a look through the rest of the changes. Presumably there are now two signs that cancel each other out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very strange, we don't really understand why these are needed, but they fix a lot of the failing tests. The signs cancel out here, so this should be the exact same expression mathematically, but it affects the stability of the tests for some reason. Obviously, all of these tests pass with the old NLexpression syntax.

Project.toml Outdated Show resolved Hide resolved
src/form/acp.jl Outdated Show resolved Hide resolved
src/form/acp.jl Outdated Show resolved Hide resolved
pseudocubic and others added 4 commits May 9, 2024 07:05
Co-authored-by: Oscar Dowson <odow@users.noreply.github.com>
This reverts commit dd61a57.
@pseudocubic
Copy link
Collaborator Author

pseudocubic commented May 9, 2024

I have reduced the changes to as few as I could to get the tests to resolve. Below is a summary of what was resolved by which changes.

Objective expressions

I added minus signs in front of gen_cost and pg for the linear terms in the objectives in the following functions:

  • _objective_mc_min_fuel_cost_polynomial_linquad
  • _objective_mc_min_fuel_cost_polynomial_nl
  • _objective_mc_min_fuel_cost_polynomial_nl_switch
  • objective_variable_pg_cost

I guess only changes to _objective_mc_min_fuel_cost_polynomial_nl and _objective_mc_min_fuel_cost_polynomial_linquad are strictly needed, but that's because of a lack of complete test coverage for the other functions, but I wanted the changes to be consistent.

These changes fixed the following testsets (9 tests total):

  • 2-bus diagonal ivr opf
  • 3-bus balanced ivr opf
  • 3-bus unbalanced ivr opf
  • capcontrol_ivr
  • test generator configuration
    • ACP/ACR tests

Power/Current balance constraints

I added minus signs in front of summations of generator power/current and inside the summation in the following functions:

  • acp.jl
    • constraint_mc_power_balance_slack
    • constraint_mc_power_balance_shed
    • constraint_mc_power_balance_shed
    • constraint_mc_power_balance_simple
    • constraint_mc_power_balance
    • constraint_mc_power_balance_capc
  • acr.jl
    • constraint_mc_power_balance
    • constraint_mc_power_balance_capc
    • constraint_mc_power_balance_shed
  • ivr.jl
    • constraint_mc_current_balance
    • constraint_mc_current_balance_capc

Strictly speaking only changes to constraint_mc_current_balance and constraint_mc_power_balance_capc are probably needed to pass the tests, but that's probably because of lack of full coverage on the others.

These changes fixed the following testsets (4 tests total):

  • 3w transformer ac pf center-tap
  • 3w transformer acp opf center-tap
  • 3w transformer acr opf center-tap
  • 3w transformer ivr opf center-tap

Load constraints

I added cancelling minus signs to expressions in the following functions:

  • acp.jl
    • constraint_mc_load_power_wye
    • constraint_mc_load_power_delta
  • acr.jl
    • constraint_mc_load_power_wye
    • constraint_mc_load_power_wye

These changes fixed the following testsets (10 tests total):

  • loadmodels connection variations

@pseudocubic
Copy link
Collaborator Author

Note that I am not yet sure exactly the problem with the branch power magnitude bound failing tests in Julia 1.6

@odow
Copy link

odow commented May 9, 2024

Okay, let me take a much deeper look here. There's obviously something weird going on. We should definitely hold off merging until we understand what.

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

Successfully merging this pull request may close these issues.

None yet

2 participants