本文整理汇总了Python中problem.Problem.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Problem.__init__方法的具体用法?Python Problem.__init__怎么用?Python Problem.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类problem.Problem
的用法示例。
在下文中一共展示了Problem.__init__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import __init__ [as 别名]
def __init__(self, fleet, environment, global_planner=None, options=None, **kwargs):
Problem.__init__(self, fleet, environment, options, label='schedulerproblem')
self.curr_state = self.vehicles[0].prediction['state'] # initial vehicle position
self.goal_state = self.vehicles[0].poseT # overall goal
self.problem_options = options # e.g. selection of problem type (freeT, fixedT)
if not 'freeT' in options:
# select default type
self.problem_options['freeT'] = True
self.start_time = 0.
self.update_times=[]
# save vehicle dimension, determines how close waypoints can be to the border
shape = self.vehicles[0].shapes[0]
if isinstance(shape, Circle):
self.veh_size = shape.radius
# used to check if vehicle fits completely in a cell
# radius is only half the vehicle size
size_to_check = self.veh_size*2
elif isinstance(shape, Rectangle):
self.veh_size = max(shape.width, shape.height)
# veh_size is complete width or height for rectangular shape
size_to_check = self.veh_size
# margin, applied to vehicle size to avoid goal positions very close to the border
self.margin = 1.1
# assign global planner
if global_planner is not None:
# save the provided planner
self.global_planner = global_planner
else:
# make a default global planner
self.global_planner = AStarPlanner(environment, [20, 20], self.curr_state, self.goal_state)
# frame settings
self.frames = []
self.cnt = 1 # frame counter
self.n_frames = options['n_frames'] if 'n_frames' in options else 1 # amount of frames to combine
if (self.n_frames > 1 and not self.problem_options['freeT']):
raise ValueError('Fixed time problems are only supported for n_frames = 1')
self._n_frames = self.n_frames # save original value
self.frame_type = options['frame_type'] if 'frame_type' in options else 'shift'
# set frame size for frame_type shift
if self.frame_type is 'shift':
# by default frame size is set to 1/5 of total environment width
self.frame_size = options['frame_size'] if 'frame_size' in options else environment.room[0]['shape'].width*0.2
# by default move limit is set to 1/4 of frame size
self.move_limit = options['move_limit'] if 'move_limit' in options else self.frame_size*0.25
if self.frame_type is 'corridor':
# scale up frame with small steps or not
self.scale_up_fine = options['scale_up_fine'] if 'scale_up_fine' in options else True
self.l_shape = options['l_shape'] if 'l_shape' in options else False
# check if vehicle size is larger than the cell size
n_cells = self.global_planner.grid.n_cells
if (size_to_check >= (min(environment.room[0]['shape'].width/float(n_cells[0]), \
environment.room[0]['shape'].height/float(n_cells[1])))
and self.frame_type == 'corridor'):
warnings.warn('Vehicle is bigger than one cell, this may cause problems' +
' when switching frames. Consider reducing the amount of cells or reducing' +
' the size of the vehicle')
示例2: __init__
# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import __init__ [as 别名]
def __init__(self, fleet, environment, n_frames, options=None):
Problem.__init__(self, fleet, environment, options, label='multiframeproblem')
self.n_frames = n_frames
if self.n_frames > len(self.environment.room):
raise RuntimeError('Number of frames you want to consider at once is larger' +
'than the amount of rooms provided in environment')
self.init_time = None
self.start_time = 0.
self.objective = 0.
示例3: __init__
# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import __init__ [as 别名]
def __init__(self, index, vehicle, problem, environment, distr_problem,
options={}):
Problem.__init__(self, vehicle, environment, options, label='admm')
self.problem = problem
self.distr_problem = distr_problem
self.vehicle = vehicle
self.environment = environment
self.group = {child.label: child for child in ([
vehicle, problem, environment, self] + environment.obstacles)}
for child in self.group.values():
child._index = index
示例4: __init__
# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import __init__ [as 别名]
def __init__(self, index, vehicle, problem, environment, distr_problem,
label, options=None):
Problem.__init__(self, vehicle, environment, options, label=label)
self.problem = problem
self.distr_problem = distr_problem
self.vehicle = vehicle
self.environment = environment
self.group = col.OrderedDict()
for child in ([vehicle, problem, environment, self] + environment.obstacles):
self.group[child.label] = child
for child in self.group.values():
child._index = index
示例5: __init__
# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import __init__ [as 别名]
def __init__(self, fleet, environment, n_segments, options=None, **kwargs):
Problem.__init__(self, fleet, environment, options, label='gcodeproblem')
self.n_segments = n_segments # amount of GCode commands to connect
if self.n_segments > len(self.environment.room):
raise RuntimeError('Number of segments to combine is larger than the amount of ' +
'GCode segments/rooms provided')
self.init_time = None
self.start_time = 0.
self.objective = 0.
# an initial guess for the motion time may be passed by the scheduler during problem creation
if 'motion_time_guess' in kwargs:
self.motion_time_guess = kwargs['motion_time_guess']
示例6: __init__
# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import __init__ [as 别名]
def __init__(self, fleet, environment, options):
Problem.__init__(self, fleet, environment, options, label='p2p')
self.init_time = None
self.start_time = 0.
示例7: __init__
# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import __init__ [as 别名]
def __init__(self):
'''constructor'''
Problem.__init__(self)
self.connection = None
示例8: __init__
# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import __init__ [as 别名]
def __init__(self):
'''constructor'''
Problem.__init__(self)
示例9: __init__
# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import __init__ [as 别名]
def __init__(self, fleet, environment, problems, updater_type, options):
self.problems = problems
self.updater_type = updater_type
Problem.__init__(self, fleet, environment, options)
示例10: __init__
# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import __init__ [as 别名]
def __init__(self, problems, updater_type, options):
self.problems = problems
self.updater_type = updater_type
vehicles = [p.vehicles[0] for p in problems]
Problem.__init__(self, vehicles, problems[0].environment, options)
示例11: __init__
# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import __init__ [as 别名]
def __init__(self, fleet, environment, options={}):
Problem.__init__(self, fleet, environment, options, label='p2p')
for vehicle in self.vehicles:
splines = vehicle.define_splines(n_seg=1)[0]
vehicle.define_trajectory_constraints(splines)
environment.define_collision_constraints(vehicle, splines)