Skip to content

Commit

Permalink
add error for negative intercept
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigomha committed Aug 30, 2024
1 parent b3634e8 commit bd8b958
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@ function _add_pwl_term!(
@warn(

Check warning on line 418 in src/devices_models/devices/common/objective_function/piecewise_linear.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/devices/common/objective_function/piecewise_linear.jl#L411-L418

Added lines #L411 - L418 were not covered by tests
"PWL has no 0.0 intercept for generator $(name). First point is given at (x = $(x_first), y = $(y_first)). Adding a first intercept at (x = 0.0, y = $(round(guess_y_zero, digits = 3)) to have equal initial slope $(slope_first)"
)
if guess_y_zero < 0.0
error(

Check warning on line 422 in src/devices_models/devices/common/objective_function/piecewise_linear.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/devices/common/objective_function/piecewise_linear.jl#L421-L422

Added lines #L421 - L422 were not covered by tests
"Added zero intercept has negative cost for generator $(name). Consider using other formulation or improve data.",
)
end
# adds a first intercept a x = 0.0 and y above the intercept of the first tuple to make convex equivalent (avoid floating point issues of almost equal slopes)
intercept_point = (x = 0.0, y = guess_y_zero + COST_EPSILON)
data = PSY.PiecewiseLinearData(vcat(intercept_point, PSY.get_points(data)))
Expand Down

0 comments on commit bd8b958

Please sign in to comment.