Class: Roby::Schedulers::Global::SchedulingGroupsGraph Private

Inherits:
Relations::BidirectionalDirectedAdjacencyGraph show all
Defined in:
lib/roby/schedulers/global.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Graph that handles scheduling groups

This graph is the main data structure of the global scheduler. Groups are set of tasks that have to be scheduled together (they form a transitive closure w.r.t. the schedule_as relation) and edges between the groups represent the schedule_as relations between the groups.

Constant Summary collapse

NOT_MY_TASK =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Object.new.freeze

Instance Attribute Summary

Attributes inherited from Relations::BidirectionalDirectedAdjacencyGraph

#backward_edges, #forward_edges_with_info

Instance Method Summary collapse

Methods inherited from Relations::BidirectionalDirectedAdjacencyGraph

#==, [], #add_edge, #add_or_update_edge, #add_vertex, #clear, #dedupe, #delete_vertex_if, #difference, #directed?, #each_edge, #each_in_neighbour, #each_out_neighbour, #each_vertex, #edge_info, #eql?, #freeze, #has_edge?, #has_vertex?, #hash, #in_degree, #in_neighbours, #initialize_copy, #leaf?, #merge, #move_edges, #num_edges, #num_vertices, #out_degree, #out_neighbours, #propagate_transitive_closure, #remove_edge, #remove_vertex, #remove_vertex_relations!, #replace, #reverse, #reverse!, #root?, #same_structure?, #set_edge_info, #to_a, #verify_consistency, #vertices

Methods included from DRoby::V5::BidirectionalGraphDumper

#droby_dump

Constructor Details

#initializeSchedulingGroupsGraph

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SchedulingGroupsGraph.



555
556
557
558
559
560
# File 'lib/roby/schedulers/global.rb', line 555

def initialize
    super

    @task_to_group = {}
    @task_to_group.compare_by_identity
end

Instance Method Details

#find_planning_task_group(group, planning_task) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Find a task's group in the special case of a planning task that plans a task from a group we know

The method uses the fact that a.planned_by(b) implies b.schedule_as(a)



576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/roby/schedulers/global.rb', line 576

def find_planning_task_group(group, planning_task)
    if (cached = @task_to_group[planning_task])
        return (cached unless cached == NOT_MY_TASK)
    end

    return group if group.include?(planning_task)

    match = each_in_neighbour(group).find do |g|
        g.include?(planning_task)
    end
    @task_to_group[planning_task] = match || NOT_MY_TASK
    match
end

#find_task_group(task) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



562
563
564
565
566
567
568
569
570
# File 'lib/roby/schedulers/global.rb', line 562

def find_task_group(task)
    if (cached = @task_to_group[task])
        return (cached unless cached == NOT_MY_TASK)
    end

    match = each_vertex.find { |g| g.include?(task) }
    @task_to_group[task] = match || NOT_MY_TASK
    match
end

#pp_group(pp, group) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



611
612
613
614
615
616
617
618
619
# File 'lib/roby/schedulers/global.rb', line 611

def pp_group(pp, group)
    pp.text "[#{group.id}] #{group.tasks.size} tasks"
    pp.nest(2) do
        group.tasks.each do |t|
            pp.breakable
            pp.text t.to_s
        end
    end
end

#pretty_print(pp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
# File 'lib/roby/schedulers/global.rb', line 590

def pretty_print(pp)
    pp.text "Scheduling group graph with #{num_vertices} groups"
    pp.nest(2) do
        each_vertex do |g|
            pp.breakable
            pp_group(pp, g)
        end
    end

    pp.nest(2) do
        pp.breakable
        pp.text "#{num_edges} edges"
        pp.nest(2) do
            each_edge do |u, v|
                pp.breakable
                pp.text "#{u.id}.schedule_as(#{v.id})"
            end
        end
    end
end