File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,19 +64,17 @@ impl Solution<'_> {
6464 pub fn create_flow_map ( & self ) -> FlowMap {
6565 // The decision variables represent assets' activity levels, not commodity flows. We
6666 // multiply this value by the flow coeffs to get commodity flows.
67- self . variables
68- . 0
69- . keys ( )
70- . zip ( self . solution . columns ( ) )
71- . flat_map ( |( ( asset, time_slice) , activity) | {
72- asset. iter_flows ( ) . map ( move |flow| {
73- (
74- ( asset. clone ( ) , flow. commodity . id . clone ( ) , time_slice. clone ( ) ) ,
75- activity * flow. coeff ,
76- )
77- } )
78- } )
79- . collect ( )
67+ let mut flows = FlowMap :: new ( ) ;
68+ for ( ( asset, time_slice) , activity) in self . variables . 0 . keys ( ) . zip ( self . solution . columns ( ) )
69+ {
70+ for flow in asset. iter_flows ( ) {
71+ let flow_key = ( asset. clone ( ) , flow. commodity . id . clone ( ) , time_slice. clone ( ) ) ;
72+ let flow_value = activity * flow. coeff ;
73+ flows. insert ( flow_key, flow_value) ;
74+ }
75+ }
76+
77+ flows
8078 }
8179
8280 /// Keys and dual values for commodity balance constraints.
You can’t perform that action at this time.
0 commit comments