public PlanTests() { _constructor1 = CreateConstructorInjectionDirective(); _constructor2 = CreateConstructorInjectionDirective(); _property = CreatePropertyInjectionDirective(); _plan = new Plan(this.GetType()); _plan.Add(_constructor1); _plan.Add(_property); _plan.Add(_constructor2); }
public When_appending_a_step_and_no_builtin_steps_are_there() { When(() => { Plan.Clear(); Plan.Add <MyEquivalencyStep>(); }); }
public IHttpActionResult Create(Plan plan) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } plan.Add(); return(Created( "", plan.Serializer() )); }
static void Test3() { Job job = new Job(); job.Name = "job"; Denisenko.Cutting.LC4.Sheet sheet = new Denisenko.Cutting.LC4.Sheet(); sheet.Amount = 1; sheet.Length = 2440; sheet.Width = 1830; sheet.Thickness = 16; job.Sheets.Add(sheet); Plan plan = new Plan(); plan.Name = "00001"; plan.LaneType = LaneType.Plate; plan.SizeType = SizeType.Changeable; plan.Copies = 1; plan.IsCopy = false; plan.Size = 1830; plan.Length = 2440; plan.TotalAmount = 50; plan.StackAmount = 1; Lage lage = new Lage(); lage.Amount = 1; lage.Postforming = false; lage.Quality = ""; lage.IsFinishPart = false; lage.BaseDetail = sheet; plan.Lagen.Add(lage); Lane cutoff1 = new Lane(); cutoff1.LaneType = LaneType.Cutoff; cutoff1.Size = 20; cutoff1.SizeType = SizeType.Automatic; plan.Add(cutoff1); Lane cut1 = new Lane(); cut1.LaneType = LaneType.Cut; cut1.Size = 4; cut1.SizeType = SizeType.Automatic; plan.Add(cut1); Lane lane1 = new Lane(); lane1.LaneType = LaneType.Lane; lane1.Size = 980; lane1.SizeType = SizeType.Changeable; plan.Add(lane1); Lane cutoff3 = new Lane(); cutoff3.LaneType = LaneType.Cutoff; cutoff3.Size = 20; cutoff3.SizeType = SizeType.Automatic; lane1.Add(cutoff3); Lane cut3 = new Lane(); cut3.LaneType = LaneType.Cut; cut3.Size = 4; cut3.SizeType = SizeType.Automatic; lane1.Add(cut3); Lane detail = new Lane(); detail.LaneType = LaneType.Detail; detail.Size = 580; detail.SizeType = SizeType.Changeable; lane1.Add(detail); Lane cut4 = new Lane(); cut4.LaneType = LaneType.Cut; cut4.Size = 4; cut4.SizeType = SizeType.Automatic; lane1.Add(cut4); Lane cutoff4 = new Lane(); cutoff4.LaneType = LaneType.Cutoff; cutoff4.Size = 1230; cutoff4.SizeType = SizeType.Automatic; lane1.Add(cutoff4); Lane cut2 = new Lane(); cut2.LaneType = LaneType.Cut; cut2.Size = 4; cut2.SizeType = SizeType.Automatic; plan.Add(cut2); Lane cutoff2 = new Lane(); cutoff2.LaneType = LaneType.Cutoff; cutoff2.Size = 1440; cutoff2.SizeType = SizeType.Automatic; plan.Add(cutoff2); job.Plans.Add(plan); job.SaveLC4("job.lc4", true); }
public When_appending_a_step() { When(() => Plan.Add <MyEquivalencyStep>()); }
public WorldModel Add(PlanModel plan) { return(new WorldModel(Entity, Task, Plan.Add(plan.Id, plan), Holding, Doing, BelongsTo)); }
/// <summary> /// Given a goal, formulates a plan. /// </summary> /// <param name="goal"></param> /// <returns></returns> public static Plan Formulate(Planner planner, StatefulAction[] actions, WorldState currentState, Goal goal) { // Reset all actions foreach (var action in actions) { action.Reset(); } // Get all valid actions whose context preconditions are true var usableActions = (from action in actions where action.contextPrecondition && !currentState.Satisfies(action.effects) select action).ToArray(); if (planner.debug) { StratusDebug.Log("Making plan to satisfy the goal '" + goal.Name + "' with preconditions:" + goal.DesiredState.ToString(), planner.agent); StratusDebug.Log("Actions available:", planner.agent); foreach (var action in usableActions) { StratusDebug.Log("- " + action.description, planner.agent); } } // The path of actions Search.Path path; if (Plan.UseAstar) { Search search = new Search(currentState, goal.DesiredState, usableActions); search.Tracing = planner.debug; search.Initialize(); path = search.FindSolution(); } else { // Build up a tree of nodes path = new Search.Path(); Search.Node starting = new Search.Node(null, 0f, goal.DesiredState, null); // Look for a solution, backtracking from the goal's desired world state until // we have fulfilled every precondition leading up to it! var hasFoundPath = FindSolution(path, starting, usableActions, planner); // If the path has not been found if (!hasFoundPath) { if (planner.debug) { StratusDebug.Log("No plan could be formulated!", planner.agent); } return(new Plan()); } } // If no solution was found if (path == null) { return(null); } // Make the plan var plan = new Plan(); foreach (var action in path) { plan.Add(action); } return(plan); }
public PersonContract(int contracrNum, PersonSubscriber client, ITariffPlan plan, List <int> phoneNums) { Subscriber = client; PhoneNumbers.AddRange(phoneNums); Plan.Add(DateTime.Today, plan); }
/// <summary> /// Reads the file and loads the plan data. /// </summary> /// <param name="file">The file with plan data.</param> /// <returns>BufferChunk. The raw array of bytes</returns> /// <exception cref="System.IO.FileNotFoundException"></exception> /// <exception cref="ReadPlanException"> /// </exception> /// <exception cref="FileNotFoundException"></exception> public virtual List <Spot> Load(string file) { if (string.IsNullOrEmpty(file) || !File.Exists(file)) { if (Globals.Debug) { Console.WriteLine(Resources.Loading_PlanData + " : " + Resources.file_not_found + " - " + file); } throw new FileNotFoundException(); } var cnt = 0; var length = 0L; try { var r = new Regex(@"\s+"); if (Globals.Debug) { Console.WriteLine(Resources.Loading_PlanData + ", " + Resources.file + " - " + file); } using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read)) { using (var sr = new StreamReader(fs, Encoding.UTF8)) { string line; while ((line = sr.ReadLine()) != null) { if (string.IsNullOrEmpty(line) || line.StartsWith("//")) { continue; } if ((line == "\n") || (line == "\r\n")) { continue; } var parts = r.Split(line); var spot = new Spot(); try { spot.id = cnt; spot.xangle = float.Parse(parts[0], CultureInfo.InvariantCulture); spot.zangle = float.Parse(parts[1], CultureInfo.InvariantCulture); spot.energy = float.Parse(parts[2], CultureInfo.InvariantCulture); spot.pcount = float.Parse(parts[3], CultureInfo.InvariantCulture); cnt++; length += Spot.Length; Plan.Add(spot); } catch (Exception ex) { if (Globals.Debug) // ActionPreference.Continue { Console.WriteLine(Resources.Failed_to_load + " PlanData (" + Resources.wrong_format_data + "), " + Resources.file + " - " + file + "\nentries = " + cnt + " " + Resources.Error + ": " + ex.Message); } throw new ReadPlanException(file); } } } if (Globals.Debug) { Console.WriteLine("PlanData" + " " + Resources.loaded + ": entries = " + cnt + ", size = " + (length / 1000.0) + " Kb"); } } if (PlanLoaded != null) { PlanLoaded.Invoke(); } return(Plan); } catch (Exception ex) { if (Globals.Debug) { Console.WriteLine(Resources.Failed_to_load + " " + "PlanData" + ", " + Resources.file + " - " + file + "\nentries = " + cnt + " " + Resources.Error + ": " + ex.Message); } throw new ReadPlanException(file); } }
bool _CreatePlan(Domain domain, List <StateVariable> worldState, Plan plan) { plan.Clear(); if (history == null) { history = new Stack <PlannerState>(); } if (taskQueue == null) { taskQueue = new List <Task>(); } if (states == null) { states = new List <StateVariable>(); } states.Clear(); taskQueue.Clear(); history.Clear(); taskQueue.Add(domain.root); states.AddRange(worldState); while (taskQueue.Count > 0) { var task = taskQueue[0]; taskQueue.RemoveAt(0); if (task is CompoundTask) { var compoundTask = task as CompoundTask; var method = compoundTask.FindSatisfiedMethod(states); if (method != null) { SaveHistory(taskQueue, plan, states); foreach (var i in method.tasks) { taskQueue.Add(domain.tasks[i.name]); } } else { if (!RestoreHistory(taskQueue, plan, states)) { return(false); } } } else { var primitiveTask = task as PrimitiveTask; if (primitiveTask.ConditionsAreValid(states)) { primitiveTask.ApplyEffects(states); plan.Add(primitiveTask); } else { if (!RestoreHistory(taskQueue, plan, states)) { return(false); } } } } return(true); }
public PlanBenchmark() { _plan = new Plan(GetType()); _plan.Add(new MyDirectiveOne()); _plan.Add(CreateConstructorInjectionDirective()); _plan.Add(CreateConstructorInjectionDirective()); _plan.Add(CreateConstructorInjectionDirective()); _plan.Add(CreateConstructorInjectionDirective()); _plan.Add(new MyDirectiveTwo()); _plan.Add(CreatePropertyInjectionDirective()); _plan.Add(CreatePropertyInjectionDirective()); _plan.Add(CreatePropertyInjectionDirective()); _plan.Add(CreatePropertyInjectionDirective()); _plan.Add(CreateMethodInjectionDirective()); }