@@ -293,4 +293,43 @@ mod tests {
293293 )
294294 . is_err( ) ) ;
295295 }
296+
297+ #[ test]
298+ fn test_check_agent_objectives ( ) {
299+ let objective1 = AgentObjective {
300+ agent_id : "agent" . into ( ) ,
301+ year : 2020 ,
302+ objective_type : ObjectiveType :: EquivalentAnnualCost ,
303+ decision_weight : None ,
304+ decision_lexico_order : Some ( 1 ) ,
305+ } ;
306+ let objective2 = AgentObjective {
307+ agent_id : "agent" . into ( ) ,
308+ year : 2020 ,
309+ objective_type : ObjectiveType :: EquivalentAnnualCost ,
310+ decision_weight : None ,
311+ decision_lexico_order : Some ( 2 ) ,
312+ } ;
313+
314+ // DecisionRule::Single
315+ let decision_rule = DecisionRule :: Single ;
316+ let objectives = [ & objective1] ;
317+ assert ! ( check_agent_objectives( & objectives, & decision_rule, "agent" , 2020 ) . is_ok( ) ) ;
318+ let objectives = [ & objective1, & objective2] ;
319+ assert ! ( check_agent_objectives( & objectives, & decision_rule, "agent" , 2020 ) . is_err( ) ) ;
320+
321+ // DecisionRule::Weighted
322+ let decision_rule = DecisionRule :: Weighted ;
323+ let objectives = [ & objective1, & objective2] ;
324+ assert ! ( check_agent_objectives( & objectives, & decision_rule, "agent" , 2020 ) . is_ok( ) ) ;
325+ let objectives = [ & objective1] ;
326+ assert ! ( check_agent_objectives( & objectives, & decision_rule, "agent" , 2020 ) . is_err( ) ) ;
327+
328+ // DecisionRule::Lexicographical
329+ let decision_rule = DecisionRule :: Lexicographical { tolerance : 1.0 } ;
330+ let objectives = [ & objective1, & objective2] ;
331+ assert ! ( check_agent_objectives( & objectives, & decision_rule, "agent" , 2020 ) . is_ok( ) ) ;
332+ let objectives = [ & objective1, & objective1] ;
333+ assert ! ( check_agent_objectives( & objectives, & decision_rule, "agent" , 2020 ) . is_err( ) ) ;
334+ }
296335}
0 commit comments