File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,10 @@ use crate::process::ProcessMap;
77use crate :: region:: RegionID ;
88use crate :: units:: Capacity ;
99use anyhow:: { Context , Result , ensure} ;
10+ use float_cmp:: approx_eq;
1011use indexmap:: IndexSet ;
1112use itertools:: Itertools ;
13+ use log:: warn;
1214use serde:: Deserialize ;
1315use std:: path:: Path ;
1416use std:: rc:: Rc ;
@@ -103,6 +105,24 @@ where
103105 asset. agent_id,
104106 ) ;
105107
108+ // Check that capacity is approximately a multiple of the process unit size
109+ // If not, raise a warning
110+ if let Some ( unit_size) = process. unit_size {
111+ let ratio = ( asset. capacity / unit_size) . value ( ) ;
112+ if !approx_eq ! ( f64 , ratio, ratio. ceil( ) ) {
113+ let n_units = ratio. ceil ( ) ;
114+ warn ! (
115+ "Asset capacity {} for process {} is not a multiple of unit size {}. \
116+ Asset will be divided into {} units with combined capacity of {}.",
117+ asset. capacity,
118+ asset. process_id,
119+ unit_size,
120+ n_units,
121+ unit_size. value( ) * n_units
122+ ) ;
123+ }
124+ }
125+
106126 Asset :: new_future_with_max_decommission (
107127 agent_id. clone ( ) ,
108128 Rc :: clone ( process) ,
You can’t perform that action at this time.
0 commit comments