Beispiel #1
0
        public new System.Object Clone()
        {
            var basePlanClone = base.Clone() as Plan;
            var newPlan       = new PlanSchedule(basePlanClone, new HashSet <Tuple <IPlanStep, IPlanStep> >(Cntgs.edges), new HashSet <Tuple <int, int> >(MM.Merges), DeLinks.Clone())
            {
                Hdepth  = hdepth,
                Decomps = Decomps
            };

            newPlan.id = id + newPlan.id;
            return(newPlan);
        }
        // Creates a clone of the plan. (orderings, and Links are Read-only, so only their host containers are replaced)
        public Object Clone()
        {
            List <IPlanStep> newSteps = new List <IPlanStep>();

            foreach (var step in steps)
            {
                // need clone because these have fulfilled conditions that are mutable.
                newSteps.Add(step.Clone() as IPlanStep);
            }

            // these are static read only things
            //IState newInitial = initial.Clone() as IState;
            //IState newGoal = goal.Clone() as IState;


            IPlanStep newInitialStep = initialStep.Clone() as IPlanStep;
            // need clone of goal step because this as fulfillable conditions
            IPlanStep newGoalStep = goalStep.Clone() as IPlanStep;

            // Assuming for now that members of the ordering graph are never mutated.  If they are, then a clone will keep references to mutated members
            Graph <IPlanStep> newOrderings = orderings.Clone() as Graph <IPlanStep>;

            // Causal Links are containers whose members are not mutated.
            List <CausalLink <IPlanStep> > newLinks = new List <CausalLink <IPlanStep> >();

            foreach (var cl in causalLinks)
            {
                newLinks.Add(cl as CausalLink <IPlanStep>);
                //newLinks.Add(cl.Clone() as CausalLink<IPlanStep>);
            }

            // Inherit all flaws, must clone very flaw
            Flawque flawList = flaws.Clone() as Flawque;

            //return new Plan(newSteps, newInitial, newGoal, newInitialStep, newGoalStep, newOrderings, newLinks, flawList);
            var p = new Plan(newSteps, Initial, Goal, newInitialStep, newGoalStep, newOrderings, newLinks, decomplinks.Clone(), flawList)
            {
                Hdepth  = hdepth,
                Decomps = decomps
            };

            p.id = id + p.id;
            return(p);
        }
Beispiel #3
0
 public PlanSchedule(IPlan plan, List <Tuple <IPlanStep, IPlanStep> > cntgs, List <Tuple <int, int> > mm, DecompositionLinks dlinks) : base(plan.Steps, plan.Initial, plan.Goal, plan.InitialStep, plan.GoalStep, plan.Orderings, plan.CausalLinks, plan.Flaws)
 {
     Cntgs   = new Schedule(cntgs);
     MM      = new MergeManager(mm);
     DeLinks = dlinks.Clone();
 }