本文整理汇总了Python中SUAVE.Core.Data.inputs方法的典型用法代码示例。如果您正苦于以下问题:Python Data.inputs方法的具体用法?Python Data.inputs怎么用?Python Data.inputs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SUAVE.Core.Data
的用法示例。
在下文中一共展示了Data.inputs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: carpet_plot
# 需要导入模块: from SUAVE.Core import Data [as 别名]
# 或者: from SUAVE.Core.Data import inputs [as 别名]
def carpet_plot(problem, number_of_points, plot_obj=1, plot_const=0):
#SUAVE.Optimization.carpet_plot(problem, ):
#takes in an optimization problem and runs a carpet plot of the first 2 variables
#unpack
opt_prob = problem.optimization_problem
idx0 = 0 #index of variable location
idx1 = 1
base_inputs = opt_prob.inputs
names = base_inputs[:,0] # Names
bnd = base_inputs[:,2] # Bounds
scl = base_inputs[:,3] # Scaling
base_objective = opt_prob.objective
obj_name = base_objective[0][0] #objective function name (used for scaling)
obj_scaling = base_objective[0][1]
base_constraints= opt_prob.constraints
constraint_names= base_constraints[:,0]
constraint_scale= base_constraints[:,3]
#define inputs, output, and constraints for sweep
inputs = np.zeros([2,number_of_points])
obj = np.zeros([number_of_points,number_of_points])
constraint_num = np.shape(base_constraints)[0] # of constraints
constraint_val = np.zeros([constraint_num,number_of_points,number_of_points])
#create inputs matrix
inputs[0,:] = np.linspace(bnd[idx0][0], bnd[idx0][1], number_of_points)
inputs[1,:] = np.linspace(bnd[idx1][0], bnd[idx1][1], number_of_points)
#inputs defined; now run sweep
for i in range(0, number_of_points):
for j in range(0,number_of_points):
#problem.optimization_problem.inputs=base_inputs #overwrite any previous modification
opt_prob.inputs[:,1][idx0]= inputs[0,i]
opt_prob.inputs[:,1][idx1]= inputs[1,j]
obj[j,i] = problem.objective()*obj_scaling
constraint_val[:,j,i]= problem.all_constraints().tolist()
if plot_obj==1:
plt.figure(0)
CS = plt.contourf(inputs[0,:],inputs[1,:], obj, linewidths=2)
cbar = plt.colorbar(CS)
cbar.ax.set_ylabel(obj_name)
plt.xlabel(names[idx0])
plt.ylabel(names[idx1])
if plot_const==1:
for i in range(0, constraint_num): #constraint_num):
plt.figure(i+1)
CS_const=plt.contour(inputs[0,:],inputs[1,:], constraint_val[i,:,:])
cbar = plt.colorbar(CS_const)
cbar.ax.set_ylabel(constraint_names[i])
plt.xlabel(names[idx0])
plt.ylabel(names[idx1])
plt.show()
#pack outputs
outputs= Data()
outputs.inputs = inputs
outputs.objective = obj
outputs.constraint_val =constraint_val
return outputs
示例2: setup
# 需要导入模块: from SUAVE.Core import Data [as 别名]
# 或者: from SUAVE.Core.Data import inputs [as 别名]
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 = Vehicles.setup()
# -------------------------------------------------------------------
# Analyses
# -------------------------------------------------------------------
nexus.analyses = Analyses.setup(nexus.vehicle_configurations)
# -------------------------------------------------------------------
# Missions
# -------------------------------------------------------------------
nexus.missions = Missions.setup(nexus.analyses)
# -------------------------------------------------------------------
# Procedure
# -------------------------------------------------------------------
nexus.procedure = Procedure.setup()
# -------------------------------------------------------------------
# Summary
# -------------------------------------------------------------------
nexus.summary = Data()
nexus.total_number_of_iterations = 0
return nexus
示例3: setup
# 需要导入模块: from SUAVE.Core import Data [as 别名]
# 或者: from SUAVE.Core.Data import inputs [as 别名]
def setup():
nexus = Nexus()
problem = Data()
nexus.optimization_problem = problem
# -------------------------------------------------------------------
# Inputs
# -------------------------------------------------------------------
# [ tag , initial, [lb,ub], scaling, units ]
problem.inputs = np.array([
[ 'wing_area' , 124.8 , ( 70. , 200. ) , 124.8 , Units.meter**2],
[ 'wing_aspect_ratio' , 10.18, ( 5. , 20. ) , 10.18, Units.less],
[ 'wing_sweep' , 25. , ( 0. , 35. ) , 25. , Units.degrees],
[ 'wing_thickness' , 0.105 , ( 0.07 , 0.20 ) , 0.105, Units.less],
[ 'design_thrust' , 52700. , ( 10000. , 70000. ) , 52700. , Units.N],
[ 'MTOW' , 79090. , ( 20000. ,100000. ) , 79090. , Units.kg],
[ 'MZFW_ratio' , 0.77 , ( 0.6 , 0.99 ) , 0.77 , Units.less],
[ 'flap_takeoff_angle' , 10. , ( 0. , 20. ) , 10. , Units.degrees],
[ 'flap_landing_angle' , 40. , ( 0. , 50. ) , 40. , Units.degrees],
[ 'short_field_TOW' , 64030. , ( 20000. ,100000. ) , 64030. , Units.kg],
[ 'design_TOW' , 68520. , ( 20000. ,100000. ) , 68520. , Units.kg],
[ 'noise_takeoff_speed_increase' , 10.0 , ( 10. , 20. ) , 10.0 , Units.knots],
[ 'noise_cutback_altitude' , 304.8 , ( 240. , 400. ) , 304.8 , Units.meter],
])
# -------------------------------------------------------------------
# Objective
# -------------------------------------------------------------------
problem.objective = np.array([
[ 'noise_cumulative_margin', 17, Units.less ],
])
# -------------------------------------------------------------------
# Constraints
# -------------------------------------------------------------------
# [ tag, sense, edge, scaling, units ]
problem.constraints = np.array([
[ 'MZFW consistency' , '>' , 0. , 10 , Units.less],
[ 'design_range_fuel_margin' , '>', 0., 10, Units.less],
[ 'short_field_fuel_margin' , '>' , 0. , 10, Units.less],
[ 'max_range_fuel_margin' , '>' , 0. , 10, Units.less],
[ 'wing_span' , '<', 35.9664, 35.9664, Units.less],
[ 'noise_flyover_margin' , '>', 0. , 10., Units.less],
[ 'noise_sideline_margin' , '>', 0. , 10. , Units.less],
[ 'noise_approach_margin' , '>', 0., 10., Units.less],
[ 'takeoff_field_length' , '<', 1985., 1985., Units.meters],
[ 'landing_field_length' , '<', 1385., 1385., Units.meters],
[ '2nd_segment_climb_max_range' , '>', 0.024, 0.024, Units.less],
[ '2nd_segment_climb_short_field' , '>', 0.024, 0.024, Units.less],
[ 'max_throttle' , '<', 1., 1., Units.less],
[ 'short_takeoff_field_length' , '<', 1330., 1330., Units.meters],
[ 'noise_cumulative_margin' , '>', 10., 10., Units.less],
])
# -------------------------------------------------------------------
# Aliases
# -------------------------------------------------------------------
problem.aliases = [
[ 'wing_area' , ['vehicle_configurations.*.wings.main_wing.areas.reference',
'vehicle_configurations.*.reference_area' ]],
[ 'wing_aspect_ratio' , 'vehicle_configurations.*.wings.main_wing.aspect_ratio' ],
[ 'wing_incidence' , 'vehicle_configurations.*.wings.main_wing.twists.root' ],
[ 'wing_tip_twist' , 'vehicle_configurations.*.wings.main_wing.twists.tip' ],
[ 'wing_sweep' , 'vehicle_configurations.*.wings.main_wing.sweeps.quarter_chord' ],
[ 'wing_thickness' , 'vehicle_configurations.*.wings.main_wing.thickness_to_chord' ],
[ 'wing_taper' , 'vehicle_configurations.*.wings.main_wing.taper' ],
[ 'wing_location' , 'vehicle_configurations.*.wings.main_wing.origin[0]' ],
[ 'horizontal_tail_area' , 'vehicle_configurations.*.wings.horizontal_stabilizer.areas.reference'],
[ 'horizontal_tail_aspect_ratio' , 'vehicle_configurations.*.wings.horizontal_stabilizer.aspect_ratio' ],
[ 'vertical_tail_area' , 'vehicle_configurations.*.wings.vertical_stabilizer.areas.reference' ],
[ 'vertical_tail_aspect_ratio' , 'vehicle_configurations.*.wings.vertical_stabilizer.aspect_ratio' ],
[ 'design_thrust' , 'vehicle_configurations.*.propulsors.turbofan.thrust.total_design' ],
[ 'MTOW' , ['vehicle_configurations.*.mass_properties.takeoff' ,
'vehicle_configurations.*.mass_properties.max_takeoff' ]],
[ 'design_TOW' , 'vehicle_configurations.base.mass_properties.takeoff' ],
[ 'short_field_TOW' , 'vehicle_configurations.short_field_takeoff.mass_properties.takeoff' ],
[ 'flap_takeoff_angle' , ['vehicle_configurations.takeoff.wings.main_wing.flaps.angle',
'vehicle_configurations.short_field_takeoff.wings.main_wing.flaps.angle']],
[ 'flap_landing_angle' , 'vehicle_configurations.landing.wings.main_wing.flaps.angle' ],
[ 'slat_takeoff_angle' , ['vehicle_configurations.takeoff.wings.main_wing.slats.angle',
'vehicle_configurations.short_field_takeoff.wings.main_wing.slats.angle']],
[ 'slat_landing_angle' , 'vehicle_configurations.landing.wings.main_wing.slats.angle' ],
[ 'wing_span' , 'vehicle_configurations.base.wings.main_wing.spans.projected' ],
[ 'noise_approach_margin' , 'summary.noise_approach_margin' ],
[ 'noise_sideline_margin' , 'summary.noise_sideline_margin' ],
[ 'noise_flyover_margin' , 'summary.noise_flyover_margin' ],
[ 'static_stability' , 'summary.static_stability' ],
[ 'vertical_tail_volume_coefficient' , 'summary.vertical_tail_volume_coefficient' ],
[ 'horizontal_tail_volume_coefficient', 'summary.horizontal_tail_volume_coefficient' ],
[ 'wing_max_cl_norm' , 'summary.maximum_cl_norm' ],
[ 'design_range_fuel_margin' , 'summary.design_range_fuel_margin' ],
#.........这里部分代码省略.........
示例4: carpet_plot
# 需要导入模块: from SUAVE.Core import Data [as 别名]
# 或者: from SUAVE.Core.Data import inputs [as 别名]
def carpet_plot(problem, number_of_points, plot_obj=1, plot_const=0, sweep_index_0=0, sweep_index_1=1):
""" Takes in an optimization problem and runs a carpet plot of the first 2 variables
sweep_index_0, sweep_index_1 is index of variables you want to run carpet plot (i.e. sweep_index_0=0 means you want to sweep first variable, sweep_index_0 = 4 is the 5th variable)
Assumptions:
N/A
Source:
N/A
Inputs:
problem [Nexus Class]
number_of_points [int]
plot_obj [int]
plot_const [int]
sweep_index_0 [int]
sweep_index_1 [int]
Outputs:
Beautiful Beautiful Plots!
Outputs:
inputs [array]
objective [array]
constraint [array]
Properties Used:
N/A
"""
#unpack
idx0 = sweep_index_0 # local name
idx1 = sweep_index_1
opt_prob = problem.optimization_problem
base_inputs = opt_prob.inputs
names = base_inputs[:,0] # Names
bnd = base_inputs[:,2] # Bounds
scl = base_inputs[:,3] # Scaling
base_objective = opt_prob.objective
obj_name = base_objective[0][0] #objective function name (used for scaling)
obj_scaling = base_objective[0][1]
base_constraints= opt_prob.constraints
constraint_names= base_constraints[:,0]
constraint_scale= base_constraints[:,3]
#define inputs, output, and constraints for sweep
inputs = np.zeros([2,number_of_points])
obj = np.zeros([number_of_points,number_of_points])
constraint_num = np.shape(base_constraints)[0] # of constraints
constraint_val = np.zeros([constraint_num,number_of_points,number_of_points])
#create inputs matrix
inputs[0,:] = np.linspace(bnd[idx0][0], bnd[idx0][1], number_of_points)
inputs[1,:] = np.linspace(bnd[idx1][0], bnd[idx1][1], number_of_points)
#inputs defined; now run sweep
for i in range(0, number_of_points):
for j in range(0,number_of_points):
#problem.optimization_problem.inputs=base_inputs #overwrite any previous modification
opt_prob.inputs[:,1][idx0]= inputs[0,i]
opt_prob.inputs[:,1][idx1]= inputs[1,j]
obj[j,i] = problem.objective()*obj_scaling
constraint_val[:,j,i]= problem.all_constraints().tolist()
if plot_obj==1:
plt.figure(0)
CS = plt.contourf(inputs[0,:],inputs[1,:], obj, linewidths=2)
cbar = plt.colorbar(CS)
cbar.ax.set_ylabel(obj_name)
plt.xlabel(names[idx0])
plt.ylabel(names[idx1])
if plot_const==1:
for i in range(0, constraint_num): #constraint_num):
plt.figure(i+1)
CS_const=plt.contour(inputs[0,:],inputs[1,:], constraint_val[i,:,:])
cbar = plt.colorbar(CS_const)
cbar.ax.set_ylabel(constraint_names[i])
plt.xlabel(names[idx0])
plt.ylabel(names[idx1])
plt.show(block=True)
#pack outputs
outputs= Data()
outputs.inputs = inputs
outputs.objective = obj
outputs.constraint_val = constraint_val
return outputs
示例5: setup
# 需要导入模块: from SUAVE.Core import Data [as 别名]
# 或者: from SUAVE.Core.Data import inputs [as 别名]
def setup():
nexus = Nexus()
problem = Data()
nexus.optimization_problem = problem
# -------------------------------------------------------------------
# Inputs
# -------------------------------------------------------------------
problem.inputs = np.array([
# Variable inputs
['wing_area', 700., (650., 725.), 500., Units.meter ** 2],
['MTOW', 207e3, (207e3, 207e3), 200e3, Units.kg],
['alt_outgoing_cruise', 13.14, (9., 14.), 13., Units.km], # 13.15 #explain the physics behing the optimizer
['design_thrust', 110e3, (100e3, 120e3), 100e3, Units.N],
['outgoing_cruise_speed', 190., (180., 212.), 200., Units['m/s']], # 191
['spray_cruise_speed', 210., (205., 212.), 200, Units['m/s']],
['cruise1_distance', 1050., (1000., 1200.), 1075., Units.km],
['cruise2_distance', 1173., (1000., 1300.), 1225., Units.km],
['cruise3_distance', 1001., (900., 1200.), 1000., Units.km],
['cruise_outgoing_distance', 3393., (3200., 3500.), 3300., Units.km],
# climb throttle as input?
# "Set" inputs
['AR', 13., (12., 14.), 13., Units.less], # aerosol released per kg of fuel ratio max?
['payload', 35e3, (35e3, 35e3), 30e3, Units.kg],
# speeds???
])
# -------------------------------------------------------------------
# Objective
# -------------------------------------------------------------------
# throw an error if the user isn't specific about wildcards
# [ tag, scaling, units ]
problem.objective = np.array([
['fuel_burn', 60000., Units.kg]
])
# -------------------------------------------------------------------
# Constraints
# -------------------------------------------------------------------
# [ tag, sense, edge, scaling, units ]
problem.constraints = np.array([
# ['min_throttle', '>', 0., 1e-1, Units.less],
['max_throttle', '<', 1., 1., Units.less],
# ['main_mission_time', '<', 11.1, 10, Units.h],
['design_range_fuel_margin', '>', 0.1, 1E-1, Units.less],
# ['take_off_field_length', '<', 2500., 2500, Units.m],
# ['landing_field_length', '<', 2500., 2500, Units.m],
['clmax', '<', 1.1, 1, Units.less],
['non_spraying_range', '>', 3500., 3500., Units.km],
['spraying_range', '>', 3500., 3500., Units.km]
# main mission range
])
# -------------------------------------------------------------------
# Aliases
# -------------------------------------------------------------------
# [ 'alias' , ['data.path1.name','data.path2.name'] ]
problem.aliases = [
['wing_area', ['vehicle_configurations.*.wings.main_wing.areas.reference',
'vehicle_configurations.*.reference_area']],
['MTOW', ['vehicle_configurations.*.mass_properties.takeoff',
"vehicle_configurations.*.mass_properties.max_takeoff"]],
['alt_outgoing_cruise', 'missions.base.segments.final_outgoing.altitude_end'],
['design_thrust', 'vehicle_configurations.*.propulsors.turbofan.thrust.total_design'],
['spray_cruise_speed', ['missions.base.segments.cruise_1.air_speed',
'missions.base.segments.cruise_2.air_speed',
'missions.base.segments.cruise_final.air_speed']],
['outgoing_cruise_speed', 'missions.base.segments.cruise_outgoing.air_speed'],
['AR', 'vehicle_configurations.*.wings.main_wing.aspect_ratio'],
['payload', ['vehicle_configurations.*.mass_properties.max_payload',
'vehicle_configurations.*.mass_properties.payload']],
['fuel_burn', 'summary.base_mission_fuelburn'],
['min_throttle', 'summary.min_throttle'],
['max_throttle', 'summary.max_throttle'],
['main_mission_time', 'summary.main_mission_time'],
['mission_range', 'summary.mission_range'],
['clmax', 'summary.clmax'],
#.........这里部分代码省略.........
示例6: line_plot
# 需要导入模块: from SUAVE.Core import Data [as 别名]
# 或者: from SUAVE.Core.Data import inputs [as 别名]
def line_plot(problem, number_of_points, plot_obj=1, plot_const=1, sweep_index=0):
"""
Takes in an optimization problem and runs a line plot of the first variable of sweep index
sweep_index. i.e. sweep_index=0 means you want to sweep the first variable, sweep_index = 4 is the 5th variable)
Assumptions:
N/A
Source:
N/A
Inputs:
problem [Nexus Class]
number_of_points [int]
plot_obj [int]
plot_const [int]
sweep_index [int]
Outputs:
Beautiful plots!
Outputs:
inputs [array]
objective [array]
constraint [array]
Properties Used:
N/A
"""
idx0 = sweep_index # local name
opt_prob = problem.optimization_problem
base_inputs = opt_prob.inputs
names = base_inputs[:,0] # Names
bnd = base_inputs[:,2] # Bounds
scl = base_inputs[:,3] # Scaling
base_objective = opt_prob.objective
obj_name = base_objective[0][0] #objective function name (used for scaling)
obj_scaling = base_objective[0][1]
base_constraints= opt_prob.constraints
constraint_names= base_constraints[:,0]
constraint_scale= base_constraints[:,3]
#define inputs, output, and constraints for sweep
inputs = np.zeros([2,number_of_points])
obj = np.zeros([number_of_points])
constraint_num = np.shape(base_constraints)[0] # of constraints
constraint_val = np.zeros([constraint_num,number_of_points])
#create inputs matrix
inputs[0,:] = np.linspace(bnd[idx0][0], bnd[idx0][1], number_of_points)
#inputs defined; now run sweep
for i in range(0, number_of_points):
opt_prob.inputs[:,1][idx0]= inputs[0,i]
obj[i] = problem.objective()*obj_scaling
constraint_val[:,i]= problem.all_constraints().tolist()
if plot_obj==1:
plt.figure(0)
plt.plot(inputs[0,:], obj, lw = 2)
plt.xlabel(names[idx0])
plt.ylabel(obj_name)
if plot_const==1:
for i in range(0, constraint_num):
plt.figure(i+1)
plt.plot(inputs[0,:], constraint_val[i,:], lw = 2)
plt.xlabel(names[idx0])
plt.ylabel(constraint_names[i])
plt.show(block=True)
#pack outputs
outputs= Data()
outputs.inputs = inputs
outputs.objective = obj
outputs.constraint_val =constraint_val
return outputs