feat: add weighted MILP objectives and voltage-drop controls#5
feat: add weighted MILP objectives and voltage-drop controls#5harrysalmon wants to merge 17 commits intovfinel:developfrom
Conversation
|
From afar it seems that this code would benefit from the new model promitives (.to_geojson(), cable tiers, and so on) introduced there |
|
This PR is a single, super heavy commit. I would recommend:
Also I understand if this is just a draft for discussion <3 |
|
|
||
| assert len(cables) == load_count | ||
| assert all(c.from_node != c.to_node for c in cables) | ||
| assert all(c.length_m > 0 for c in cables) |
0177125 to
1e03e1d
Compare
|
awesome work ! I've successfully ran the test on my computer. I could only have a quick look though, i'll let @vperron have a look at the code too :) |
vperron
left a comment
There was a problem hiding this comment.
This, friends, is helluva cool PR. 👍
| @classmethod | ||
| def capacity_w(cls) -> float: | ||
| """Capacity of this cable type independent of the instance.""" | ||
| return float(cls.num_phases) * V0 * PF * cls.max_current_a |
There was a problem hiding this comment.
from an electrical engineering point of view, it is a bit weird to compute a cable capacity in watts (because it depends on the voltage -that can vary because of voltage drop-, and ultimately, cables are rated in amps). It would make more sense to keep capacity in amps, and convert the active power of the load (in watts) to current drawn (in amps).
There was a problem hiding this comment.
Helpful, thanks! I've cleared up the name and expanded the docstring to make this clear.
Yeah definitely, as they share the same signiture it should be fairly easy to run each and contrast them visually and numerically. It's ready to merge now if you're happy with it @vfinel :D |
|
Awesome, thanks for the clarification! Let's merge and continue to build up on this. Thanks for your contribution ! This is going places. Amazing places ! |
|
Oups, just a CI error to fix linked to ruff linting, and then we can merge ;) |
Summary
src/nopywer/optimize_milp.pywith a combined formulation for topology, cable tier selection, and power flow.weight_costweight_lengthweight_power_distanceweight_voltage_dropweight_cumulative_voltage_dropmax_voltage_drop_percentandmax_voltage_drop_percent_by_nodetests/optimization/test_optimize_milp.pytests/optimization/test_contracts.pytests/api/test_optimize_endpoint.pycolocacion/frontend/public/data/nw25/power-lines.geojsonpower-nodes.geojsonunchanged.