<s> from numpy import sqrt <EOL> from openmdao . main . datatypes . api import ListStr , Float , Array , Event , List <EOL> from openmdao . main . component import Component <EOL> from openmdao . main . uncertain_distributions import NormalDistribution <EOL> class Pareto_Min_Dist ( Component ) : <EOL> """<STR_LIT>""" <EOL> pareto = List ( [ ] , iotype = "<STR_LIT>" , <EOL> desc = "<STR_LIT>" ) <EOL> criteria = ListStr ( iotype = "<STR_LIT>" , dtype = "<STR_LIT:str>" , <EOL> desc = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> predicted_values = Array ( iotype = "<STR_LIT>" , dtype = NormalDistribution , <EOL> desc = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> dist = Float ( <NUM_LIT:0.0> , iotype = "<STR_LIT>" , <EOL> desc = "<STR_LIT>" ) <EOL> reset_pareto = Event ( ) <EOL> def __init__ ( self ) : <EOL> super ( Pareto_Min_Dist , self ) . __init__ ( ) <EOL> self . y_star_other = None <EOL> def _reset_pareto_fired ( self ) : <EOL> self . y_star_other = None <EOL> def get_pareto ( self ) : <EOL> y_star_other = [ ] <EOL> c = [ ] <EOL> for single_case_list in self . pareto : <EOL> for case in single_case_list : <EOL> for objective in case . outputs : <EOL> for crit in self . criteria : <EOL> if crit in objective [ <NUM_LIT:0> ] : <EOL> c . append ( objective [ <NUM_LIT:2> ] ) <EOL> if c != [ ] : <EOL> y_star_other . append ( c ) <EOL> c = [ ] <EOL> return y_star_other <EOL> def _calc_min_dist ( self , p , y_star_other ) : <EOL> """<STR_LIT>""" <EOL> dists = [ ] <EOL> for y in y_star_other : <EOL> d = sqrt ( sum ( [ ( A - B ) ** <NUM_LIT:2> for A , B in zip ( p , y ) ] ) ) <EOL> dists . append ( d ) <EOL> return min ( dists ) <EOL> def execute ( self ) : <EOL> mu = [ objective . mu for objective in self . predicted_values ] <EOL> if self . y_star_other == None : <EOL> self . y_star_other = self . get_pareto ( ) <EOL> self . dist = self . _calc_min_dist ( mu , self . y_star_other ) </s>
