def __init__(self, impl=None, stepMode=True): """ Constructor """ ActivityBase.ActivityBase.__init__(self, LOG, stepMode) if impl != None: self.__impl = impl else: self.__impl = None if self.stepMode == True: LOG.info('Step mode on') else: LOG.info('Step mode off') # Set instances for actions self.__procedure1_impl = Procedure1Impl.Procedure1Impl() self.__procedure1 = Procedure1.Procedure1(self.__procedure1_impl, stepMode) self.__procedure2_impl = Procedure2Impl.Procedure2Impl() self.__procedure2 = Procedure2.Procedure2(self.__procedure2_impl, stepMode) self.__procedure3_impl = Procedure3Impl.Procedure3Impl() self.__procedure3 = Procedure3.Procedure3(self.__procedure3_impl, stepMode) # 'exec_status' is marked "Current" initially or "Continuous" if the # action will run multiple times, and marked True if executed. # 'tok_list' is list of input tokens for the action. # 'controlInput marks input control pins. self.actdict = { 'initialNode': { 'stdin': 'auto', 'next_step': ['Procedure1'] }, 'Procedure1': { 'controlInput': { 'source': 'initialNode', 'min_tok': 1, 'max_tok': 1, 'tok_list': [] }, 'method': self.Procedure1, 'next_step': 'Procedure2', 'exec_status': "Current" }, 'Procedure2': { 'argument': { 'source': 'Procedure1', 'min_tok': 1, 'max_tok': 3, 'tok_list': [] }, 'method': self.Procedure2, 'next_step': 'Procedure3', 'exec_status': "Current" }, 'Procedure3': { 'argument': { 'source': 'Procedure2', 'min_tok': 1, 'max_tok': 5, 'tok_list': [] }, 'method': self.Procedure3, 'next_step': 'return output parameters', 'exec_status': "Current" }, 'final': { 'controlInput': { 'source': 'Procedure3', 'min_tok': 1, 'max_tok': 1, 'tok_list': [] }, 'method': self.final, 'next_step': None, 'exec_status': "Current" }, 'result': { 'stdout': 'no', # If yes returns output and exit, else query 'final': { 'source': 'Procedure3', 'tok_list': [] } } } self.result_map_dict = { "initialNode": ["Procedure1.controlInput"], "Procedure1.result": ["Procedure2.argument"], "Procedure2.result": ["Procedure3.argument"], "Procedure3.controlOutput": ["final.controlInput"], "Procedure3.result": ["result.final"] }
def setup(): nexus = Nexus() problem = Data() nexus.optimization_problem = problem # ------------------------------------------------------------------- # Inputs # ------------------------------------------------------------------- # [ tag , initial, (lb,ub) , scaling , units ] problem.inputs = np.array([ [ 'wing_area' , 95 , ( 90. , 130. ) , 100. , Units.meter**2], [ 'cruise_altitude' , 11 , ( 9 , 14. ) , 10. , Units.km], ]) # ------------------------------------------------------------------- # Objective # ------------------------------------------------------------------- # throw an error if the user isn't specific about wildcards # [ tag, scaling, units ] problem.objective = np.array([ [ 'fuel_burn', 10000, Units.kg ] ]) # ------------------------------------------------------------------- # Constraints # ------------------------------------------------------------------- # [ tag, sense, edge, scaling, units ] problem.constraints = np.array([ [ 'design_range_fuel_margin' , '>', 0., 1E-1, Units.less], #fuel margin defined here as fuel ]) # ------------------------------------------------------------------- # Aliases # ------------------------------------------------------------------- # [ 'alias' , ['data.path1.name','data.path2.name'] ] problem.aliases = [ [ 'wing_area' , ['vehicle_configurations.*.wings.main_wing.areas.reference', 'vehicle_configurations.*.reference_area' ]], [ 'cruise_altitude' , 'missions.base.segments.climb_5.altitude_end' ], [ 'fuel_burn' , 'summary.base_mission_fuelburn' ], [ 'design_range_fuel_margin' , 'summary.max_zero_fuel_margin' ], ] # ------------------------------------------------------------------- # Vehicles # ------------------------------------------------------------------- nexus.vehicle_configurations = Vehicles2.setup() # ------------------------------------------------------------------- # Analyses # ------------------------------------------------------------------- nexus.analyses = Analyses2.setup(nexus.vehicle_configurations) # ------------------------------------------------------------------- # Missions # ------------------------------------------------------------------- nexus.missions = Missions2.setup(nexus.analyses) # ------------------------------------------------------------------- # Procedure # ------------------------------------------------------------------- nexus.procedure = Procedure2.setup() # ------------------------------------------------------------------- # Summary # ------------------------------------------------------------------- nexus.summary = Data() return nexus
def setup(): nexus = Nexus() problem = Data() nexus.optimization_problem = problem # ------------------------------------------------------------------- # Inputs # ------------------------------------------------------------------- # [ tag , initial, (lb,ub) , scaling , units ] problem.inputs = np.array([ ['wing_area', 95, (90., 130.), 100., Units.meter**2], ['cruise_altitude', 11, (9, 14.), 10., Units.km], ]) # ------------------------------------------------------------------- # Objective # ------------------------------------------------------------------- # throw an error if the user isn't specific about wildcards # [ tag, scaling, units ] problem.objective = np.array([['fuel_burn', 10000, Units.kg]]) # ------------------------------------------------------------------- # Constraints # ------------------------------------------------------------------- # [ tag, sense, edge, scaling, units ] problem.constraints = np.array([ ['design_range_fuel_margin', '>', 0., 1E-1, Units.less], #fuel margin defined here as fuel ]) # ------------------------------------------------------------------- # Aliases # ------------------------------------------------------------------- # [ 'alias' , ['data.path1.name','data.path2.name'] ] problem.aliases = [ [ 'wing_area', [ 'vehicle_configurations.*.wings.main_wing.areas.reference', 'vehicle_configurations.*.reference_area' ] ], ['cruise_altitude', 'missions.base.segments.climb_5.altitude_end'], ['fuel_burn', 'summary.base_mission_fuelburn'], ['design_range_fuel_margin', 'summary.max_zero_fuel_margin'], ] # ------------------------------------------------------------------- # Vehicles # ------------------------------------------------------------------- nexus.vehicle_configurations = Vehicles2.setup() # ------------------------------------------------------------------- # Analyses # ------------------------------------------------------------------- nexus.analyses = Analyses2.setup(nexus.vehicle_configurations) # ------------------------------------------------------------------- # Missions # ------------------------------------------------------------------- nexus.missions = Missions2.setup(nexus.analyses) # ------------------------------------------------------------------- # Procedure # ------------------------------------------------------------------- nexus.procedure = Procedure2.setup() # ------------------------------------------------------------------- # Summary # ------------------------------------------------------------------- nexus.summary = Data() return nexus