Beispiel #1
0
class InformedPlanner(GenericGraphPlanner):
    """
        This one knows that some plans are redundant
    """
    def __init__(self,
                 diffeo_structure_params,
                 pre_expand=[],
                 *args,
                 **kwargs):
        super(InformedPlanner, self).__init__(*args, **kwargs)
        self.diffeo_structure_params = diffeo_structure_params
        self.pre_expand = pre_expand

    def __str__(self):
        return 'InformedPlanner(%s)' % (self.__strparams__())

    def __strparams__(self):
        # TODO: use classes
        p = GenericGraphPlanner.__strparams__(self)
        return p

    @contract(dds=DiffeoSystem)
    def init(self, id_dds, dds):
        self.ds = DiffeoStructure(dds=dds, **self.diffeo_structure_params)
        self.original_dds = dds
        dds_expanded = diffeosystem_expand(dds,
                                           pr=self.ds.get_plan_reducer(),
                                           heuristics=self.pre_expand)

        # TODO: recompute structure

        self.info('pre_expand: %s' % str(self.pre_expand))
        self.info('Expanded to %s from %s actions' %
                  (len(dds_expanded.actions), len(dds.actions)))

        super(InformedPlanner, self).init(id_dds, dds_expanded)

    def plan(self, y0, y1, precision, min_visibility):
        # we need to translate back the result according to the original plan
        result = super(InformedPlanner, self).plan(y0, y1, precision,
                                                   min_visibility)
        if result.success:
            plan_extended = result.plan
            self.info('Solution found in extended space: %s' %
                      str(plan_extended))
            plan_simple = self.get_dds().plan_with_simple_actions(
                plan_extended)
            self.info('With simple actions: %s' % str(plan_simple))
            result.plan = plan_simple
        return result

    @contract(report=Report)
    def init_report(self, report):
        """ Creates a report for the initialization phase. """
        super(InformedPlanner, self).init_report(report)
        self.ds.display(report.section('diffeo_structure'))

    def get_plan_reducer(self):
        return self.ds.get_plan_reducer()
Beispiel #2
0
def show_diffeo_structure(dds, report, tolerance):
    ds = DiffeoStructure(dds, tolerance=tolerance)
    with report.subsection('display') as r:
        ds.display(r)

    with report.subsection('show_reduction_steps') as r:
        ds.show_reduction_steps(r, max_nsteps=5)

    with report.subsection('show_reduction') as r:
        ds.show_reduction(r)
def show_diffeo_structure(dds, report, tolerance):
    ds = DiffeoStructure(dds, tolerance=tolerance)
    with report.subsection('display') as r:
        ds.display(r)
    
    with report.subsection('show_reduction_steps') as r:
        ds.show_reduction_steps(r, max_nsteps=5)
        
    with report.subsection('show_reduction') as r:
        ds.show_reduction(r)
class InformedPlanner(GenericGraphPlanner):
    """
        This one knows that some plans are redundant
    """
    def __init__(self, diffeo_structure_params, pre_expand=[],
                 *args, **kwargs):
        super(InformedPlanner, self).__init__(*args, **kwargs)
        self.diffeo_structure_params = diffeo_structure_params
        self.pre_expand = pre_expand
        
    def __str__(self):
        return 'InformedPlanner(%s)' % (self.__strparams__())
        
    def __strparams__(self):
        # TODO: use classes
        p = GenericGraphPlanner.__strparams__(self)
        return p 

    @contract(dds=DiffeoSystem)
    def init(self, id_dds, dds):
        self.ds = DiffeoStructure(dds=dds, **self.diffeo_structure_params)
        self.original_dds = dds
        dds_expanded = diffeosystem_expand(dds, pr=self.ds.get_plan_reducer(),
                                           heuristics=self.pre_expand)
        
        # TODO: recompute structure
         
        self.info('pre_expand: %s' % str(self.pre_expand))
        self.info('Expanded to %s from %s actions' % 
                  (len(dds_expanded.actions), len(dds.actions)))
        
        super(InformedPlanner, self).init(id_dds, dds_expanded)
        
    
    def plan(self, y0, y1, precision, min_visibility):
        # we need to translate back the result according to the original plan
        result = super(InformedPlanner, self).plan(y0, y1, precision, min_visibility)
        if result.success:
            plan_extended = result.plan
            self.info('Solution found in extended space: %s' % str(plan_extended))
            plan_simple = self.get_dds().plan_with_simple_actions(plan_extended)
            self.info('With simple actions: %s' % str(plan_simple))
            result.plan = plan_simple
        return result
        
    @contract(report=Report)
    def init_report(self, report):
        """ Creates a report for the initialization phase. """
        super(InformedPlanner, self).init_report(report)
        self.ds.display(report.section('diffeo_structure'))
 
    def get_plan_reducer(self):
        return self.ds.get_plan_reducer()
Beispiel #5
0
def report_dds_geometry(id_discdds, tolerance):
    dds = get_conftools_discdds().instance(id_discdds)
    r = Report('dds_geometry-%s-%s' % (id_discdds, tolerance))
    ds = DiffeoStructure(dds, tolerance=tolerance)
    with r.subsection('display') as r:
        ds.display(r)

    with r.subsection('show_reduction_steps') as r:
        ds.show_reduction_steps(r, max_nsteps=5)

    with r.subsection('show_reduction') as r:
        ds.show_reduction(r)

    return r
def report_dds_geometry(id_discdds, tolerance):
    dds = get_conftools_discdds().instance(id_discdds)
    r = Report('dds_geometry-%s-%s' % (id_discdds, tolerance))
    ds = DiffeoStructure(dds, tolerance=tolerance)
    with r.subsection('display') as r:
        ds.display(r)
    
    with r.subsection('show_reduction_steps') as r:
        ds.show_reduction_steps(r, max_nsteps=5)
        
    with r.subsection('show_reduction') as r:
        ds.show_reduction(r)
        
    return r