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

Variable Cost Refactor Part 2: PowerSimulations #73

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/library/psi_library.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ function _duplicate_system(main_sys::PSY.System, twin_sys::PSY.System, HVDC_line
if ix ∈ [1, length(old_pwl_array)]
noise_val, rand_ix = iterate(noise_values, rand_ix)
cost_noise = 50.0 * noise_val
new_pwl_array[ix] = (x, (y + cost_noise))
new_pwl_array[ix] = (x = x, y = (y + cost_noise))
else
try_again = true
while try_again
Expand All @@ -1474,12 +1474,12 @@ function _duplicate_system(main_sys::PSY.System, twin_sys::PSY.System, HVDC_line
noise_val, rand_ix = iterate(noise_values, rand_ix)
power_noise = 0.01 * noise_val
slope_previous =
((y + cost_noise) - old_pwl_array[ix - 1][1]) /
((x - power_noise) - old_pwl_array[ix - 1][2])
((y + cost_noise) - old_pwl_array[ix - 1].y) /
((x - power_noise) - old_pwl_array[ix - 1].x)
slope_next =
(-(y + cost_noise) + old_pwl_array[ix + 1][1]) /
(-(x - power_noise) + old_pwl_array[ix + 1][2])
new_pwl_array[ix] = ((x - power_noise), (y + cost_noise))
(-(y + cost_noise) + old_pwl_array[ix + 1].y) /
(-(x - power_noise) + old_pwl_array[ix + 1].x)
new_pwl_array[ix] = (x = (x - power_noise), y = (y + cost_noise))
try_again = slope_previous > slope_next
if rand_ix == length(noise_values)
break
Expand Down
Loading