Commit 0cad8de
committed
The Weights API is now used in the modeling equations:
Changes made:
1. elements.py - Flow tracking:
# Before:
flow_hours = self.flow_rate * self._model.timestep_duration
weighted_flow_hours = flow_hours * self._model.cluster_weight
tracked_expression=weighted_flow_hours.sum(self._model.temporal_dims)
# After:
tracked_expression=self._model.weights.sum_temporal(self.flow_rate)
2. elements.py - Load factor total hours:
# Before:
total_hours = (self._model.timestep_duration * self._model.cluster_weight).sum(self._model.temporal_dims)
# After:
total_hours = self._model.weights.temporal.sum(self._model.weights.temporal_dims)
3. features.py - Status tracking:
# Before:
active_hours = self.status * self._model.timestep_duration
weighted_active_hours = active_hours * self._model.cluster_weight
tracked_expression=weighted_active_hours.sum(self._model.temporal_dims)
# After:
tracked_expression=self._model.weights.sum_temporal(self.status)
4. features.py - Temporal effects summing (only needs cluster weight since already per-timestep):
# Before:
weighted_per_timestep = self.total_per_timestep * self._model.cluster_weight
temporal_dims = [d for d in self.total_per_timestep.dims if d not in ('period', 'scenario')]
# After:
weighted_per_timestep = self.total_per_timestep * self._model.weights.cluster
self._eq_total.lhs -= weighted_per_timestep.sum(dim=self._model.weights.temporal_dims)1 parent 9d00c80 commit 0cad8de
2 files changed
Lines changed: 8 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | 680 | | |
684 | 681 | | |
685 | 682 | | |
686 | | - | |
| 683 | + | |
687 | 684 | | |
688 | 685 | | |
689 | 686 | | |
| |||
840 | 837 | | |
841 | 838 | | |
842 | 839 | | |
843 | | - | |
844 | | - | |
| 840 | + | |
| 841 | + | |
845 | 842 | | |
846 | 843 | | |
847 | 844 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 199 | + | |
| 200 | + | |
204 | 201 | | |
205 | 202 | | |
206 | | - | |
| 203 | + | |
207 | 204 | | |
208 | 205 | | |
209 | 206 | | |
| |||
630 | 627 | | |
631 | 628 | | |
632 | 629 | | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
| 630 | + | |
| 631 | + | |
637 | 632 | | |
638 | 633 | | |
639 | 634 | | |
| |||
0 commit comments