File tree Expand file tree Collapse file tree
src/simulation/optimisation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,7 +75,14 @@ pub fn add_asset_constraints(
7575 // need to add different constraints for assets with flexible and non-flexible flows.
7676 //
7777 // See: https://github.com/EnergySystemsModellingLab/MUSE_2.0/issues/360
78- add_fixed_asset_constraints ( problem, variables, assets, & model. time_slice_info ) ;
78+ add_fixed_asset_constraints (
79+ problem,
80+ variables,
81+ assets,
82+ & model. time_slice_info ,
83+ & commodity_balance_keys,
84+ & capacity_keys,
85+ ) ;
7986
8087 // Return constraint keys
8188 ConstraintKeys {
@@ -231,7 +238,16 @@ fn add_fixed_asset_constraints(
231238 variables : & VariableMap ,
232239 assets : & AssetPool ,
233240 time_slice_info : & TimeSliceInfo ,
241+ commodity_balance_keys : & CommodityBalanceConstraintKeys ,
242+ capacity_keys : & CapacityConstraintKeys ,
234243) {
244+ // Sanity check: we rely on the dual rows corresponding to these constraints being
245+ // immediately after the commodity balance and capacity constraints in `problem`.
246+ assert ! (
247+ problem. num_rows( ) == commodity_balance_keys. len( ) + capacity_keys. len( ) ,
248+ "Fixed asset constraints must be added immediately after commodity constraints."
249+ ) ;
250+
235251 for asset in assets. iter ( ) {
236252 // Get first PAC. unwrap is safe because all processes have at least one PAC.
237253 let pac1 = asset. iter_pacs ( ) . next ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments