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

Remove old debugging code #137

Merged
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
17 changes: 0 additions & 17 deletions prescient/engine/egret/egret_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,23 +519,6 @@ def solve_deterministic_day_ahead_pricing_problem(solver, ruc_results, options,

ptdf_manager.update_active(pricing_results)

## Debugging
if pricing_results.data['system']['total_cost'] > ruc_results.data['system']['total_cost'] and not \
math.isclose(pricing_results.data['system']['total_cost'],
ruc_results.data['system']['total_cost'],
rel_tol=1e-06, abs_tol=1e-06):
print("The pricing run had a higher objective value than the MIP run. This is indicative of a bug.")
print(f"pricing run cost: {pricing_results.data['system']['total_cost']}")
print(f"MIP run cost : {ruc_results.data['system']['total_cost']}")
print("Writing LP pricing_problem.json")
output_filename = 'pricing_instance.json'
pricing_results.write(output_filename)

output_filename = 'ruc_results.json'
ruc_results.write(output_filename)

raise RuntimeError("Halting due to bug in pricing.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this an actual error? Alternatively, should this at least log a warning?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe? Based on @xiangao1's experience it's hard to say.

This was originally some sanity-checking code I had added. But I think due to MIP tolerances (e.g., 0.99999 is "integer") the objective function after fixing the binaries can be arbitrarily far away from the objective function reported by the MIP solve. In theory, of course, the all of the price methods fix and/or relax binary variables from the MIP solve, which should result in a no-higher objective value.

In the end I thought just eliminating this code was best, because I think it gives too many false-positives. But I'm open to making this a warning.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK - I am all for removing the exception. I am torn if leaving in a warning would be useful.


day_ahead_prices = {}
for b, b_dict in pricing_results.elements(element_type='bus'):
for t,lmp in enumerate(b_dict['lmp']['values']):
Expand Down