-
Notifications
You must be signed in to change notification settings - Fork 67
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
[DO NOT MERGE] Notes os JuMP issues #1218
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -606,6 +606,7 @@ function _make_flow_expressions!( | |
sum( | ||
ptdf_col[i] * nodal_balance_expressions[i, t] for | ||
i in 1:length(ptdf_col) | ||
# maybe only sum if nonempy? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ignore |
||
) | ||
) | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1633,10 +1633,10 @@ function add_to_expression!( | |
device_base_power, | ||
) | ||
for t in time_steps | ||
fuel_expr = variable[name, t] * prop_term_per_unit * dt | ||
JuMP.add_to_expression!( | ||
expression[name, t], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for more info: |
||
fuel_expr, | ||
prop_term_per_unit * dt, | ||
variable[name, t], | ||
) | ||
end | ||
elseif value_curve isa PSY.QuadraticCurve | ||
|
@@ -1709,22 +1709,33 @@ function add_to_expression!( | |
for t in time_steps | ||
sos_status = _get_sos_value(container, W, d) | ||
if sos_status == SOSStatusVariable.NO_VARIABLE | ||
bin = 1.0 | ||
JuMP.add_to_expression!( | ||
expression[name, t], | ||
P_min * prop_term_per_unit * dt, | ||
) | ||
elseif sos_status == SOSStatusVariable.PARAMETER | ||
param = get_default_on_parameter(d) | ||
bin = get_parameter(container, param, V).parameter_array[name, t] | ||
JuMP.add_to_expression!( | ||
expression[name, t], | ||
P_min * prop_term_per_unit * dt, | ||
bin | ||
) | ||
elseif sos_status == SOSStatusVariable.VARIABLE | ||
var = get_default_on_variable(d) | ||
bin = get_variable(container, var, V)[name, t] | ||
JuMP.add_to_expression!( | ||
expression[name, t], | ||
P_min * prop_term_per_unit * dt, | ||
bin | ||
) | ||
else | ||
@assert false | ||
end | ||
fuel_expr = | ||
variable[name, t] * prop_term_per_unit * dt + | ||
P_min * bin * prop_term_per_unit * dt | ||
JuMP.add_to_expression!( | ||
expression[name, t], | ||
fuel_expr, | ||
prop_term_per_unit * dt, | ||
variable[name, t], | ||
) | ||
end | ||
elseif value_curve isa PSY.QuadraticCurve | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,7 +196,8 @@ function device_duration_look_ahead!( | |
lhs_off = JuMP.GenericAffExpr{Float64, JuMP.VariableRef}(0) | ||
for i in UnitRange{Int}(Int(t - duration_data[ix].down + 1), t) | ||
if i in time_steps | ||
JuMP.add_to_expression!(lhs_off, (1 - varon[name, i])) | ||
JuMP.add_to_expression!(lhs_off, 1) | ||
JuMP.add_to_expression!(lhs_off, -1, varon[name, i]) | ||
Comment on lines
-199
to
+200
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the previous allocates more because |
||
end | ||
end | ||
if t <= duration_data[ix].down | ||
|
@@ -322,7 +323,8 @@ function device_duration_parameters!( | |
for i in UnitRange{Int}(Int(t - duration_data[ix].down + 1), t) | ||
if t <= duration_data[ix].down | ||
if in(i, time_steps) | ||
JuMP.add_to_expression!(lhs_off, (1 - varon[name, i])) | ||
JuMP.add_to_expression!(lhs_off, 1) | ||
JuMP.add_to_expression!(lhs_off, -1, varon[name, i]) | ||
end | ||
else | ||
JuMP.add_to_expression!(lhs_off, varstop[name, i]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,11 +137,12 @@ function _get_pwl_cost_expression( | |
name = PSY.get_name(component) | ||
pwl_var_container = get_variable(container, PieceWiseLinearBlockOffer(), T) | ||
gen_cost = JuMP.AffExpr(0.0) | ||
cost_data = PSY.get_y_coords(cost_data) | ||
for (i, cost) in enumerate(cost_data) | ||
_cost_data = PSY.get_y_coords(cost_data) | ||
for (i, cost) in enumerate(_cost_data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. type instability There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fixed in main now for the cases that don't user market bid. There is a PR to refactor that code that will incorporate this change |
||
JuMP.add_to_expression!( | ||
gen_cost, | ||
cost * multiplier * pwl_var_container[(name, i, time_period)], | ||
cost * multiplier, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
pwl_var_container[(name, i, time_period)], | ||
) | ||
end | ||
return gen_cost | ||
|
@@ -196,7 +197,8 @@ function _get_pwl_cost_expression( | |
for i in 1:length(slopes) | ||
JuMP.add_to_expression!( | ||
ordc_cost, | ||
slopes[i] * multiplier * pwl_var_container[(name, i, time_period)], | ||
slopes[i] * multiplier, | ||
pwl_var_container[(name, i, time_period)], | ||
) | ||
end | ||
return ordc_cost | ||
|
@@ -241,7 +243,8 @@ function _get_pwl_cost_expression( | |
for (i, cost) in enumerate(cost_data) | ||
JuMP.add_to_expression!( | ||
gen_cost, | ||
cost * multiplier * pwl_var_container[(name, i, time_period)], | ||
cost * multiplier, | ||
pwl_var_container[(name, i, time_period)], | ||
) | ||
end | ||
return gen_cost | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The AGC functionality is offline for now. We need LHS parameters to revive it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. POI is much better nowadays. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These improvements should make it to main |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,10 +60,12 @@ function add_constraints!( | |
for t in time_steps | ||
resource_expression = JuMP.GenericAffExpr{Float64, JuMP.VariableRef}() | ||
for reserve_variable in reserve_variables | ||
JuMP.add_to_expression!(resource_expression, sum(reserve_variable[:, t])) | ||
JuMP.add_to_expression!(resource_expression, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this more effective than pre-allocating the expression in 61? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure I got what you mean |
||
JuMP.@expression(container.JuMPmodel, sum(reserve_variable[:, t]))) | ||
# consider a for loop to add the reserve variables | ||
end | ||
if use_slacks | ||
resource_expression += slack_vars[t] | ||
JuMP.add_to_expression!(resource_expression, slack_vars[t]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch |
||
end | ||
constraint[service_name, t] = | ||
JuMP.@constraint(container.JuMPmodel, resource_expression >= requirement) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These ones are quite important too. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,19 +161,23 @@ function add_constraints!( | |
param = get_parameter_column_refs(param_container, service_name) | ||
for t in time_steps | ||
if use_slacks | ||
resource_expression = sum(reserve_variable[:, t]) + slack_vars[t] | ||
resource_expression = JuMP.@expression( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this could be related to #1000 |
||
jump_model, sum(reserve_variable[:, t]) + slack_vars[t]) | ||
else | ||
resource_expression = sum(reserve_variable[:, t]) | ||
resource_expression = JuMP.@expression( | ||
jump_model, sum(reserve_variable[:, t])) | ||
end | ||
constraint[service_name, t] = | ||
JuMP.@constraint(jump_model, resource_expression >= param[t] * requirement) | ||
end | ||
else | ||
for t in time_steps | ||
if use_slacks | ||
resource_expression = sum(reserve_variable[:, t]) + slack_vars[t] | ||
resource_expression = JuMP.@expression( | ||
jump_model, sum(reserve_variable[:, t]) + slack_vars[t]) | ||
else | ||
resource_expression = sum(reserve_variable[:, t]) | ||
resource_expression = JuMP.@expression( | ||
jump_model, sum(reserve_variable[:, t])) | ||
end | ||
constraint[service_name, t] = JuMP.@constraint( | ||
jump_model, | ||
|
@@ -268,9 +272,11 @@ function add_constraints!( | |
jump_model = get_jump_model(container) | ||
for t in time_steps | ||
resource_expression = JuMP.GenericAffExpr{Float64, JuMP.VariableRef}() | ||
JuMP.add_to_expression!(resource_expression, sum(reserve_variable[:, t])) | ||
JuMP.add_to_expression!(resource_expression, | ||
JuMP.@expression(jump_model, sum(reserve_variable[:, t]))) | ||
# consider a for loop | ||
if use_slacks | ||
resource_expression += slack_vars[t] | ||
JuMP.add_to_expression!(resource_expression, slack_vars[t]) | ||
end | ||
constraint[service_name, t] = | ||
JuMP.@constraint(jump_model, resource_expression >= requirement) | ||
|
@@ -553,6 +559,7 @@ function add_proportional_cost!( | |
for index in Iterators.product(axes(reserve_variable)...) | ||
add_to_objective_invariant_expression!( | ||
container, | ||
# possibly decouple | ||
DEFAULT_RESERVE_COST / base_p * reserve_variable[index...], | ||
) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before add didn't work for mixed ExpressionTypes. We can re-test