public void OrthonormalBasisTest() { var p = new CSP(); p.MaxSteps = 10000000; var v1 = new Vector3Variable("v1", p, box); var v2 = new Vector3Variable("v2", p, box); var v3 = new Vector3Variable("v3", p, box); v1.Magnitude.MustEqual(1); v2.Magnitude.MustEqual(1); v3.Magnitude.MustEqual(1); v1.MustBePerpendicular(v2); v2.MustBePerpendicular(v3); v3.MustBePerpendicular(v1); for (int count = 0; count < 10; count++) { p.NewSolution(); double magnitude = Math.Sqrt(v1.X * v1.X + v1.Y * v1.Y + v1.Z * v1.Z); Assert.IsTrue(MathUtil.NearlyEqual(magnitude, 1), "Magnitude not unity; was: " + magnitude); double dotProduct = v1.X * v2.X + v1.Y * v2.Y + v1.Z * v2.Z; Assert.IsTrue(MathUtil.NearlyEqual(dotProduct, 0), "Dot product not zero; was: " + dotProduct); magnitude = Math.Sqrt(v2.X * v2.X + v2.Y * v2.Y + v2.Z * v2.Z); Assert.IsTrue(MathUtil.NearlyEqual(magnitude, 1), "Magnitude not unity; was: " + magnitude); dotProduct = v2.X * v3.X + v2.Y * v3.Y + v2.Z * v3.Z; Assert.IsTrue(MathUtil.NearlyEqual(dotProduct, 0), "Dot product not zero; was: " + dotProduct); magnitude = Math.Sqrt(v3.X * v3.X + v3.Y * v3.Y + v3.Z * v3.Z); Assert.IsTrue(MathUtil.NearlyEqual(magnitude, 1), "Magnitude not unity; was: " + magnitude); dotProduct = v3.X * v1.X + v3.Y * v1.Y + v3.Z * v1.Z; Assert.IsTrue(MathUtil.NearlyEqual(dotProduct, 0), "Dot product not zero; was: " + dotProduct); } }
public Vector3Variable(string name, CSP p, Interval x, Interval y, Interval z) { Name = name; X = new FloatVariable(name + ".X", p, x); Y = new FloatVariable(name + ".Y", p, y); Z = new FloatVariable(name + ".Z", p, z); }
public void EvenPowerNegativeATest() { var p = new CSP(); var a = new FloatVariable("a", p, -3, 0); var power = a ^ 2; power.MustEqual(4f); p.TestConsistency(); AssertUnique(a, -2f); }
public void DifferenceTest() { var p = new CSP(); var a = new FloatVariable("a", p, 0, 1); var b = new FloatVariable("b", p, 0, 1); var difference = a - b; a.MustEqual(0.5f); b.MustEqual(0.25f); p.TestConsistency(); AssertUnique(difference, 0.25f); }
public void testConstraintNetwork() { CSP csp = new CSP(variables); csp.addConstraint(C1); csp.addConstraint(C2); Assert.assertNotNull(csp.getConstraints()); Assert.assertEquals(2, csp.getConstraints().size()); Assert.assertNotNull(csp.getConstraints(X)); Assert.assertEquals(2, csp.getConstraints(X).size()); Assert.assertNotNull(csp.getConstraints(Y)); Assert.assertEquals(2, csp.getConstraints(Y).size()); Assert.assertNotNull(csp.getConstraints(Z)); Assert.assertEquals(0, csp.getConstraints(Z).size()); }
public void DotProductOneVectorFixedTest() { var p = new CSP(); var eX = new Vector3Variable("eX", p, 1, 0, 0); var unknown = new Vector3Variable("unknown", p, box); var dot = Vector3Variable.Dot(eX, unknown); dot.MustEqual(0); for (int count = 0; count < 1000; count++) { p.NewSolution(); Assert.IsTrue(MathUtil.NearlyEqual(unknown.X.UniqueValue, 0)); } }
public void DotProductTest() { var p = new CSP(); var v1 = new Vector3Variable("v1", p, box); var v2 = new Vector3Variable("v2", p, box); var dot = Vector3Variable.Dot(v1, v2); dot.MustEqual(0); for (int count = 0; count < 1000; count++) { p.NewSolution(); double dotProduct = v1.X.UniqueValue * v2.X.UniqueValue + v1.Y.UniqueValue * v2.Y.UniqueValue + v1.Z.UniqueValue * v2.Z.UniqueValue; Assert.IsTrue(MathUtil.NearlyEqual(dotProduct, 0), "Dot product not zero; was: "+dotProduct); } }
public void T_IsConsistant_True_SameLine() { // Arrange CSP csp = new CSP(); PrivateObject obj = new PrivateObject(csp); GraphNode gn0 = new GraphNode(new Cell(9, 6)); gn0.Cell.Value = '9'; GraphNode gn1 = new GraphNode(new Cell(9, 2)); gn1.Cell.Value = '2'; GraphNode gn2 = new GraphNode(new Cell(9, 0)); gn2.Cell.Value = '3'; csp.Nodes.Add(gn0); csp.Nodes.Add(gn1); csp.Nodes.Add(gn2); GraphArc ga01 = new GraphArc(gn0, gn1); GraphArc ga02 = new GraphArc(gn0, gn2); gn0.ConnectedArcs = new List <GraphArc> { ga01, ga02 }; GraphArc ga10 = new GraphArc(gn1, gn0); GraphArc ga12 = new GraphArc(gn1, gn2); gn1.ConnectedArcs = new List <GraphArc> { ga10, ga12 }; GraphArc ga20 = new GraphArc(gn2, gn0); GraphArc ga21 = new GraphArc(gn2, gn1); gn2.ConnectedArcs = new List <GraphArc> { ga20, ga21 }; // Act var isConsistant = obj.Invoke("IsConsistant"); // Assert Assert.IsInstanceOfType(isConsistant, typeof(bool), "Wrong type."); Assert.IsTrue((bool)isConsistant, "Wrong value."); }
/** * Removes all values from the domain of <code>var</code> which are not consistent with * <code>constraint</code> and <code>assignment</code>. Modifies the domain log accordingly so * that all changes can be undone later on. */ private bool revise(VAR var, IConstraint <VAR, VAL> constraint, Assignment <VAR, VAL> assignment, CSP <VAR, VAL> csp, DomainLog <VAR, VAL> log) { bool revised = false; foreach (VAL value in csp.getDomain(var)) { assignment.add(var, value); if (!constraint.isSatisfiedWith(assignment)) { log.storeDomainFor(var, csp.getDomain(var)); csp.removeValueFromDomain(var, value); revised = true; } assignment.remove(var); } return(revised); }
public ActionResult CSPs_Read([DataSourceRequest] DataSourceRequest request, CSPFilterViewModel filter) { IQueryable <CSP> items = CSP.GetAll(filter.StudentId, filter.TeacherId, filter.SchoolId, filter.SchoolYearId, filter.SubjectId, filter.ClassId).AsQueryable(); DataSourceResult result = items.ToDataSourceResult(request, _item => new { Id = _item.Id, StudentName = _item.StudentName, StudentClass = _item.StudentClass, SchoolName = _item.SchoolName, SubjectName = _item.SubjectName, TeacherNames = _item.TeacherNames, Materials = _item.Materials, SchoolYearName = _item.SchoolYearName, CreatedOn = _item.CreatedOn, CreatedByUserName = _item.CreatedByUserName }); return(Json(result)); }
private bool Revise(Var var, IConstraint <Var, Val> constraint, Assignment <Var, Val> assignment, CSP <Var, Val> csp, DomainLog <Var, Val> log) { bool revised = false; foreach (var value in csp.GetDomain(var)) { assignment.Add(var, value); if (!constraint.IsSatisfiedWith(assignment)) { log.StoreDomainFor(var, csp.GetDomain(var)); csp.RemoveValueFromDomain(var, value); revised = true; } assignment.Remove(var); } return(revised); }
public void testConstraintNetwork() { CSP <Variable, string> csp = new CSP <Variable, string>(variables); csp.addConstraint(C1); csp.addConstraint(C2); csp.addConstraint(C3); csp.addConstraint(C4); Assert.IsNotNull(csp.getConstraints()); Assert.AreEqual(4, csp.getConstraints().Size()); Assert.IsNotNull(csp.getConstraints(WA)); Assert.AreEqual(1, csp.getConstraints(WA).Size()); Assert.IsNotNull(csp.getConstraints(NT)); Assert.AreEqual(2, csp.getConstraints(NT).Size()); Assert.IsNotNull(csp.getConstraints(Q)); Assert.AreEqual(2, csp.getConstraints(Q).Size()); Assert.IsNotNull(csp.getConstraints(NSW)); Assert.AreEqual(2, csp.getConstraints(NSW).Size()); }
/// <summary> /// Build the Craft.CSP object from the constraints and variables. /// </summary> void MakeCSP() { CSP = new CSP { MaxSteps = this.MaxSolverSteps }; foreach (var v in Variables) { v.MakeVariable(CSP); } //this.DumpVariables(); foreach (var c in Constraints) { if (c != null && c.Trim() != "") { BuildConstraint(c); } } //this.DumpVariables(); }
/** * For efficiency reasons the queue manages updated variables vj whereas the original AC3 * manages neighbor arcs (vi, vj). Constraints which are not binary are ignored. */ private void reduceDomains(ICollection <VAR> queue, CSP <VAR, VAL> csp, DomainLog <VAR, VAL> log) { while (!queue.IsEmpty()) { VAR var = queue.Pop(); foreach (IConstraint <VAR, VAL> constraint in csp.getConstraints(var)) { VAR neighbor = csp.getNeighbor(var, constraint); if (neighbor != null && revise(neighbor, var, constraint, csp, log)) { if (csp.getDomain(neighbor).isEmpty()) { log.setEmptyDomainFound(true); return; } queue.Add(neighbor); } } } }
public List <Coordinate> generateFromParalellTrackDatum(Coordinate datum, int numLegs, double orientation, double legDistance, double trackSpacing, bool firstTurnRight) { Coordinate CSP; double turnDegrees; if (firstTurnRight) { turnDegrees = 90; } else { turnDegrees = -90; } CSP = datum.travel(3 * trackSpacing / 2, orientation - turnDegrees); CSP = CSP.travel(legDistance / 2, orientation + 180); generatePattern(CSP, numLegs, orientation, legDistance, trackSpacing, firstTurnRight); return(points); }
/** * Removes all values from the domains of the neighbor variables of <code>var</code> in the * constraint graph which are not consistent with the new value for <code>var</code>. * It is called after <code>assignment</code> has (recursively) been extended with a value * assignment for <code>var</code>. */ public IInferenceLog <VAR, VAL> apply(CSP <VAR, VAL> csp, Assignment <VAR, VAL> assignment, VAR var) { DomainLog <VAR, VAL> log = new DomainLog <VAR, VAL>(); foreach (IConstraint <VAR, VAL> constraint in csp.getConstraints(var)) { VAR neighbor = csp.getNeighbor(var, constraint); if (neighbor != null && !assignment.contains(neighbor)) { if (revise(neighbor, constraint, assignment, csp, log)) { if (csp.getDomain(neighbor).isEmpty()) { log.setEmptyDomainFound(true); return(log); } } } } return(log); }
public IInferenceLog <Var, Val> Apply(CSP <Var, Val> csp, Assignment <Var, Val> assignment, Var var) { var log = new DomainLog <Var, Val>(); foreach (var constraint in csp.GetConstraints(var)) { Var neighbor = csp.GetNeighbor(var, constraint); if (neighbor != null && !assignment.Contains(neighbor)) { if (Revise(neighbor, constraint, assignment, csp, log)) { if (!csp.GetDomain(neighbor).Any()) { log.SetEmptyDomainFound(true); return(log); } } } } return(log); }
public void testDomainChanges() { Domain <string> colors2 = new Domain <string>(colors.asList()); Assert.AreEqual(colors, colors2); CSP <Variable, string> csp = new CSP <Variable, string>(variables); csp.addConstraint(C1); Assert.IsNotNull(csp.getDomain(X)); Assert.AreEqual(0, csp.getDomain(X).size()); Assert.IsNotNull(csp.getConstraints(X)); csp.setDomain(X, colors); Assert.AreEqual(colors, csp.getDomain(X)); Assert.AreEqual(3, csp.getDomain(X).size()); Assert.AreEqual("red", csp.getDomain(X).get(0)); CSP <Variable, string> cspCopy = csp.copyDomains(); Assert.IsNotNull(cspCopy.getDomain(X)); Assert.AreEqual(3, cspCopy.getDomain(X).size()); Assert.AreEqual("red", cspCopy.getDomain(X).get(0)); Assert.IsNotNull(cspCopy.getDomain(Y)); Assert.AreEqual(0, cspCopy.getDomain(Y).size()); Assert.IsNotNull(cspCopy.getConstraints(X)); Assert.AreEqual(C1, cspCopy.getConstraints(X).Get(0)); cspCopy.removeValueFromDomain(X, "red"); Assert.AreEqual(2, cspCopy.getDomain(X).size()); Assert.AreEqual("green", cspCopy.getDomain(X).get(0)); Assert.AreEqual(3, csp.getDomain(X).size()); Assert.AreEqual("red", csp.getDomain(X).get(0)); cspCopy.setDomain(X, animals); Assert.AreEqual(2, cspCopy.getDomain(X).size()); Assert.AreEqual("cat", cspCopy.getDomain(X).get(0)); Assert.AreEqual(3, csp.getDomain(X).size()); Assert.AreEqual("red", csp.getDomain(X).get(0)); }
static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: CNG462_A2 <mapfilename> <wordlist>"); Environment.Exit(1); } ReadFiles(args[0], args[1]); try { char[][] ResultMatrix = new CSP(Matrix, Domain).Solve(); Console.WriteLine("Solution has been found!"); Console.WriteLine(""); CSP.PrintMatrix(ResultMatrix); } catch (InvalidOperationException) { Console.WriteLine("A valid solution could not be found!"); } }
/** * Reduces the domain of the specified variable to the specified value and * reestablishes arc-consistency. It is assumed that the provided CSP was * arc-consistent before the call. * * @return An object which indicates success/failure and contains data to * undo the operation. */ public IInferenceLog <VAR, VAL> apply(CSP <VAR, VAL> csp, Assignment <VAR, VAL> assignment, VAR var) { Domain <VAL> domain = csp.getDomain(var); VAL value = assignment.getValue(var); if (!domain.contains(value)) { throw new Exception("domain does not contain value"); } DomainLog <VAR, VAL> log = new DomainLog <VAR, VAL>(); if (domain.size() > 1) { ICollection <VAR> queue = CollectionFactory.CreateFifoQueue <VAR>(); queue.Add(var); log.storeDomainFor(var, domain); csp.setDomain(var, new Domain <VAL>(value)); reduceDomains(queue, csp, log); } return(log.compactify()); }
public void testCSPSolver() { CSP <Variable, string> csp = new CSP <Variable, string>(variables); csp.addConstraint(C1); csp.addConstraint(C2); csp.addConstraint(C3); csp.addConstraint(C4); csp.setDomain(WA, colors); csp.setDomain(NT, colors); csp.setDomain(Q, colors); csp.setDomain(NSW, colors); csp.setDomain(V, colors); TreeCspSolver <Variable, string> treeCSPSolver = new TreeCspSolver <Variable, string>(); Assignment <Variable, string> assignment = treeCSPSolver.solve(csp); Assert.IsTrue(assignment != null); Assert.IsTrue(assignment.isComplete(csp.getVariables())); Assert.IsTrue(assignment.isSolution(csp)); }
public void DotProductTest() { var p = new CSP(); var v1 = new Vector3Variable("v1", p, box); var v2 = new Vector3Variable("v2", p, box); var dot = Vector3Variable.Dot(v1, v2); dot.MustEqual(0); for (int count = 0; count < 1000; count++) { try { p.NewSolution (); } catch (Exception e) { Console.Write ("Finding a new solution failed due to: "); Console.WriteLine (e); Assert.Fail (); } double dotProduct = v1.X.UniqueValue * v2.X.UniqueValue + v1.Y.UniqueValue * v2.Y.UniqueValue + v1.Z.UniqueValue * v2.Z.UniqueValue; Assert.IsTrue(MathUtil.NearlyEqual(dotProduct, 0), "Dot product not zero; was: "+dotProduct); } }
public void T_GenerateArcs_SameColumn() { // Arrange CSP csp = new CSP(); GraphNode gn0 = new GraphNode(new Cell(0, 9)); GraphNode gn1 = new GraphNode(new Cell(3, 9)); GraphNode gn2 = new GraphNode(new Cell(9, 9)); csp.Nodes.Add(gn0); csp.Nodes.Add(gn1); csp.Nodes.Add(gn2); GraphArc ga01 = new GraphArc(gn0, gn1); GraphArc ga02 = new GraphArc(gn0, gn2); GraphArc ga10 = new GraphArc(gn1, gn0); GraphArc ga12 = new GraphArc(gn1, gn2); GraphArc ga20 = new GraphArc(gn2, gn0); GraphArc ga21 = new GraphArc(gn2, gn1); // Act csp.GenerateArcs(); // Assert CollectionAssert.AreEqual( gn0.ConnectedArcs, new List <GraphArc>(new GraphArc[] { ga01, ga02 }) ); CollectionAssert.AreEqual( gn1.ConnectedArcs, new List <GraphArc>(new GraphArc[] { ga10, ga12 }) ); CollectionAssert.AreEqual( gn2.ConnectedArcs, new List <GraphArc>(new GraphArc[] { ga20, ga21 }) ); }
public void EqualityConstraintTest() { { var p = new CSP(); var a = new FloatVariable("a", p, 0, 1); var b = new FloatVariable("b", p, 0, 1); var c = new FloatVariable("c", p); c.MustEqual(b); var sum = a + b; sum.MustEqual(1); for (int i = 0; i < 10; i++) { p.NewSolution(); Assert.IsTrue(MathUtil.NearlyEqual(sum.UniqueValue, (a.UniqueValue + b.UniqueValue))); Assert.AreEqual(c.Value, b.Value); } } { var p = new CSP(); var a = new FloatVariable("a", p, 0, 1); var b = new FloatVariable("b", p, 0, 1); var c = new FloatVariable("c", p); b.MustEqual(c); var sum = a + b; sum.MustEqual(1); for (int i = 0; i < 10; i++) { p.NewSolution(); Assert.IsTrue(MathUtil.NearlyEqual(sum.UniqueValue, (a.UniqueValue + b.UniqueValue))); Assert.AreEqual(c.Value, b.Value); } } }
public void testDomainChanges() { Domain colors2 = new Domain(colors.asList()); Assert.assertEquals(colors, colors2); CSP csp = new CSP(variables); csp.addConstraint(C1); Assert.assertNotNull(csp.getDomain(X)); Assert.assertEquals(0, csp.getDomain(X).size()); Assert.assertNotNull(csp.getConstraints(X)); csp.setDomain(X, colors); Assert.assertEquals(colors, csp.getDomain(X)); Assert.assertEquals(3, csp.getDomain(X).size()); Assert.assertEquals("red", csp.getDomain(X).get(0)); CSP cspCopy = csp.copyDomains(); Assert.assertNotNull(cspCopy.getDomain(X)); Assert.assertEquals(3, cspCopy.getDomain(X).size()); Assert.assertEquals("red", cspCopy.getDomain(X).get(0)); Assert.assertNotNull(cspCopy.getDomain(Y)); Assert.assertEquals(0, cspCopy.getDomain(Y).size()); Assert.assertNotNull(cspCopy.getConstraints(X)); Assert.assertEquals(C1, cspCopy.getConstraints(X).get(0)); cspCopy.removeValueFromDomain(X, "red"); Assert.assertEquals(2, cspCopy.getDomain(X).size()); Assert.assertEquals("green", cspCopy.getDomain(X).get(0)); Assert.assertEquals(3, csp.getDomain(X).size()); Assert.assertEquals("red", csp.getDomain(X).get(0)); cspCopy.setDomain(X, animals); Assert.assertEquals(2, cspCopy.getDomain(X).size()); Assert.assertEquals("cat", cspCopy.getDomain(X).get(0)); Assert.assertEquals(3, csp.getDomain(X).size()); Assert.assertEquals("red", csp.getDomain(X).get(0)); }
public JsonResult SaveCSPNotes(int itemId, string comment, string febNotes, string juneNotes) { CSP.SaveCSPNotes(itemId, comment, febNotes, juneNotes); return(Json(true, JsonRequestBehavior.AllowGet)); }
public void SumTest() { var p = new CSP(); var a = new FloatVariable("a", p, 0, 1); var b = new FloatVariable("b", p, 0, 1); var sum = a + b; a.MustEqual(0.5f); b.MustEqual(0.25f); p.TestConsistency(); AssertUnique(sum, 0.75f); }
internal void MakeVariable(CSP csp) { if (Component != null) { if (Type == typeof(float)) MakeFloatVariable(csp); else if (Type == typeof(Vector3)) MakeVector3Variable(csp); else throw new Exception(string.Format("Variable {0} must be a float or Vector3 variable", VariableName)); } else { // ReSharper disable CompareOfFloatsByEqualityOperator if (MinY == 0 && MinZ == 0 && MaxY == 0 && MaxZ == 0) // ReSharper restore CompareOfFloatsByEqualityOperator this.MakeFloatVariable(csp); else this.MakeVector3Variable(csp); } }
public void Undo(CSP <Var, Val> csp) { _savedDomain.ForEach(pair => csp.SetDomain(pair.Key, pair.Value)); }
public void UnitVectorTest() { var p = new CSP(); var v = new Vector3Variable("v", p, box); v.Magnitude.MustEqual(1); for (int count = 0; count < 1000; count++) { p.NewSolution(); double magnitude = Math.Sqrt(v.X*v.X+v.Y*v.Y+v.Z*v.Z); Assert.IsTrue(MathUtil.NearlyEqual(magnitude, 1), "Magnitude not unity; was: " + magnitude); } }
public void undo(CSP <VAR, VAL> csp) { }
public void OddPowerPositiveTest() { var p = new CSP(); var a = new FloatVariable("a", p, -3, 3); var power = a ^ 3; a.MustEqual(2f); p.TestConsistency(); AssertUnique(power, 8f); }
///<summary> ///Removes the given CSP ///</summary> public void RemoveCSP(CSP toRemove) { this.RemoveStructure("CSP", toRemove); }
public Criptografia(string base64SaltKey) { _csp = new CSP(base64SaltKey); }
private void MakeVector3Variable(CSP csp) { this.mVector3Variable = new Vector3Variable(VariableName, csp, new BoundingBox(new Interval(Min, Max), new Interval(MinY, MaxY), new Interval(MinZ, MaxZ))); }
public ActionResult PreviousCSP(int id) { int nextId = CSP.GetPreviousCSP(id); return(RedirectToAction("Notes", new { id = nextId })); }
public void setUp() { csp = new MapCSP(); }
public ActionResult MoveOrderDown(int id) { CSP _item = CSPGoalCatalog.MoveDown(id); return(RedirectToAction("Notes", new { id = _item.Id })); }
public void ProductTest() { var p = new CSP(); var a = new FloatVariable("a", p, 0, 1); var b = new FloatVariable("b", p, 0, 1); var product = a * b; a.MustEqual(0.5f); b.MustEqual(0.5f); p.TestConsistency(); AssertUnique(product, 0.25f); }
public void QuotientTest() { var p = new CSP(); var a = new FloatVariable("a", p, 0, 1); var b = new FloatVariable("b", p, 0, 1); var quotient = a / b; a.MustEqual(0.5f); b.MustEqual(0.5f); p.TestConsistency(); AssertUnique(quotient, 1); }
public IInferenceLog <Var, Val> Apply(CSP <Var, Val> csp) { return(new EmptyLog <Var, Val>()); }
public void QuadraticTest() { var p = new CSP(); var a = new FloatVariable("a", p, -100, 100); var b = new FloatVariable("b", p, -100, 100); var quad = (a^2) + b; bool fail = false; quad.NarrowTo(new Interval(10, 20), ref fail); for (int i = 0; i < 1000; i++) { p.NewSolution(); Assert.IsTrue(MathUtil.NearlyEqual(quad.UniqueValue, (a.UniqueValue * a.UniqueValue + b.UniqueValue))); } }
public void UnconstrainedSumTest() { var p = new CSP(); var a = new FloatVariable("a", p, 0, 1); var b = new FloatVariable("b", p, 0, 1); var sum = a + b; for (int i = 0; i < 1000; i++) { p.NewSolution(); Assert.IsTrue(MathUtil.NearlyEqual(sum.UniqueValue, (a.UniqueValue + b.UniqueValue))); } }
/// <summary> /// The CSP is not changed at the beginning. /// </summary> /// <param name="csp"></param> /// <returns></returns> public IInferenceLog <VAR, VAL> apply(CSP <VAR, VAL> csp) { return(new InferenceEmptyLog <VAR, VAL>()); }
private void MakeFloatVariable(CSP csp) { this.mFloatVariable = new FloatVariable(VariableName, csp, new Interval(Min, Max)); }
static void Main(string[] args) { ////int h, int w, int n, int seed //ProblemMap pm = new ProblemMap(10, 10, 10, 1); ////ProblemMap pm = new ProblemMap(4,4,5, 1); //pm.RandomizeConnections(ref pm.vertices); //int numberOfColors = 5; //Dictionary<Vertex, List<int>> domains = new Dictionary<Vertex, List<int>>(); //foreach (Vertex vertex in pm.vertices) //{ // List<int> colors = new List<int>(); // for (int i = 1; i <= numberOfColors; i++) // { // colors.Add(i); // } // domains.Add(vertex, colors); //} //CSP<Vertex, int> csp = new CSP<Vertex, int>(pm.vertices, domains); //List<Vertex> checkedVertices = new List<Vertex>(); //// Add Constraints //foreach (Vertex vertex in domains.Keys) //{ // foreach (Vertex neighbour in vertex.Neighbors) // { // if (!checkedVertices.Contains(neighbour)) // csp.AddConstraint(new MapColoringConstraint(vertex, neighbour)); // } // checkedVertices.Add(vertex); //} FileStream fs = new FileStream("data.txt", FileMode.Create); using StreamWriter writeText = new StreamWriter(fs); List <int> BTNodes = new List <int>(); List <double> BTFirsts = new List <double>(); List <double> BTTotal = new List <double>(); List <int> FCNodes = new List <int>(); List <double> FCFirsts = new List <double>(); List <double> FCTotal = new List <double>(); int func1 = 3, func2 = 7; foreach (int i in new int[] { func1, func2 }) { Console.WriteLine("\n\ni: " + i); switch (i) { case 1: writeText.WriteLine("\n\nBacktrackingSearch MVR enabled"); writeText.WriteLine("BacktrackingSearch LCV enabled"); break; case 2: writeText.WriteLine("\n\nBacktrackingSearch MVR enabled"); writeText.WriteLine("BacktrackingSearch LCV disabled"); break; case 3: writeText.WriteLine("\n\nBacktrackingSearch MVR disabled"); writeText.WriteLine("BacktrackingSearch LCV disabled"); break; case 4: writeText.WriteLine("\n\nBacktrackingSearch MVR disabled"); writeText.WriteLine("BacktrackingSearch LCV enabled"); break; case 5: writeText.WriteLine("\n\nForwardChecking MVR enabled"); writeText.WriteLine("ForwardChecking LCV enabled"); break; case 6: writeText.WriteLine("\n\nForwardChecking MVR enabled"); writeText.WriteLine("ForwardChecking LCV disabled"); break; case 7: writeText.WriteLine("\n\nForwardChecking MVR disabled"); writeText.WriteLine("ForwardChecking LCV disabled"); break; case 8: writeText.WriteLine("\n\nForwardChecking MVR disabled"); writeText.WriteLine("ForwardChecking LCV enabled"); break; case 9: writeText.WriteLine("\n\n--AC3-- ForwardChecking MVR disabled"); writeText.WriteLine("ForwardChecking LCV enabled"); break; default: break; } for (int n = 2; n <= 14; n++) { Console.WriteLine("\n\nn: " + n); //int h, int w, int n, int seed ProblemMap pm = new ProblemMap(10, 10, n, 5); //ProblemMap pm = new ProblemMap(4,4,5, 1); pm.RandomizeConnections(ref pm.vertices); int numberOfColors = 4; Dictionary <Vertex, List <int> > domains = new Dictionary <Vertex, List <int> >(); foreach (Vertex vertex in pm.vertices) { List <int> colors = new List <int>(); for (int j = 1; j <= numberOfColors; j++) { colors.Add(j); } domains.Add(vertex, colors); } CSP <Vertex, int> csp = new CSP <Vertex, int>(pm.vertices, domains); List <Vertex> checkedVertices = new List <Vertex>(); // Add Constraints foreach (Vertex vertex in domains.Keys) { foreach (Vertex neighbour in vertex.Neighbors) { if (!checkedVertices.Contains(neighbour)) { csp.AddConstraint(new MapColoringConstraint(vertex, neighbour)); } } checkedVertices.Add(vertex); } Tuple <List <Dictionary <Vertex, int> >, int, List <int> > solutions; switch (i) { case 1: solutions = csp.BacktrackingSearch(); solutions = csp.BacktrackingSearch(); break; case 2: csp.LCVEnabled = false; solutions = csp.BacktrackingSearch(); solutions = csp.BacktrackingSearch(); break; case 3: csp.MRVEnabled = false; csp.LCVEnabled = false; solutions = csp.BacktrackingSearch(); solutions = csp.BacktrackingSearch(); break; case 4: csp.LCVEnabled = true; csp.MRVEnabled = false; solutions = csp.BacktrackingSearch(); solutions = csp.BacktrackingSearch(); break; case 5: csp.MRVEnabled = true; solutions = csp.ForwardChecking(); solutions = csp.ForwardChecking(); break; case 6: csp.LCVEnabled = false; solutions = csp.ForwardChecking(); solutions = csp.ForwardChecking(); break; case 7: csp.MRVEnabled = false; csp.LCVEnabled = false; solutions = csp.ForwardChecking(); solutions = csp.ForwardChecking(); break; case 8: csp.LCVEnabled = true; csp.MRVEnabled = false; solutions = csp.ForwardChecking(); solutions = csp.ForwardChecking(); break; case 9: csp.MRVEnabled = true; solutions = csp.AC3(); solutions = csp.AC3(); break; default: solutions = csp.BacktrackingSearch(); break; } if (i == func1) { BTNodes.Add(solutions.Item2); BTFirsts.Add(csp.FirstSolutionTime.TotalSeconds); BTTotal.Add(csp.FinishedTime.TotalSeconds); } else if (i == func2) { FCNodes.Add(solutions.Item2); FCFirsts.Add(csp.FirstSolutionTime.TotalSeconds); FCTotal.Add(csp.FinishedTime.TotalSeconds); } //foreach (var vertex in pm.vertices) //{ // writeText.WriteLine($"\nPunkt {vertex.Point.X}:{vertex.Point.Y}"); // foreach (var neighbour in vertex.Neighbors) // { // writeText.WriteLine($"{neighbour.Point.X}:{neighbour.Point.Y}"); // } //} //writeText.WriteLine($"ConsistenceCounter\t{solutions.Item2}"); //writeText.WriteLine($"Total Time:\t{csp.FinishedTime.TotalSeconds}\nFirst solution time:\t{csp.FirstSolutionTime.TotalSeconds}"); //int index = 1; if (solutions.Item1.Count != 0) { Console.WriteLine("Found solution"); } } } writeText.Write("\nn"); for (int z = 2; z <= BTNodes.Count + 1; z++) { writeText.Write($"\t{z}"); } writeText.Write("\nBT"); for (int z = 2; z <= BTNodes.Count + 1; z++) { writeText.Write($"\t{BTNodes[z - 2]}"); } writeText.Write("\nFC"); for (int z = 2; z <= BTNodes.Count + 1; z++) { writeText.Write($"\t{FCNodes[z - 2]}"); } writeText.Write("\n\nFirst Solution Time"); writeText.Write("\nn"); for (int z = 2; z <= BTNodes.Count + 1; z++) { writeText.Write($"\t{z}"); } writeText.Write("\nBT"); for (int z = 2; z <= BTNodes.Count + 1; z++) { writeText.Write($"\t{BTFirsts[z - 2]}"); } writeText.Write("\nFC"); for (int z = 2; z <= BTNodes.Count + 1; z++) { writeText.Write($"\t{FCFirsts[z - 2]}"); } writeText.Write("\n\nTotal Time"); writeText.Write("\nn"); for (int z = 2; z <= BTNodes.Count + 1; z++) { writeText.Write($"\t{z}"); } writeText.Write("\nBT"); for (int z = 2; z <= BTNodes.Count + 1; z++) { writeText.Write($"\t{BTTotal[z - 2]}"); } writeText.Write("\nFC"); for (int z = 2; z <= BTNodes.Count + 1; z++) { writeText.Write($"\t{FCTotal[z - 2]}"); } }
protected Variable(string name, CSP p) { Name = name; p.Variables.Add(this); CSP = p; }
/// <summary> /// Build the Craft.CSP object from the constraints and variables. /// </summary> void MakeCSP() { CSP = new CSP { MaxSteps = this.MaxSolverSteps }; foreach (var v in Variables) { v.MakeVariable(CSP); } //this.DumpVariables(); foreach (var c in Constraints) { if (c!=null && c.Trim() != "") BuildConstraint(c); } //this.DumpVariables(); }
protected Constraint(CSP p) { CSP = p; p.Constraints.Add(this); }
/// <summary> /// Constructs an HL7 segment for the specified Segments enum object /// </summary> /// <param name="seg">The Segments enum object to construct for</param> public Segment(Segments seg) { switch (seg) { case Segments.ABS: ABS abs = new ABS(); Name = abs.Name; Description = abs.Description; Fields = abs.Fields; break; case Segments.ACC: ACC acc = new ACC(); Name = acc.Name; Description = acc.Description; Fields = acc.Fields; break; case Segments.ADD: ADD add = new ADD(); Name = add.Name; Description = add.Description; Fields = add.Fields; break; case Segments.AFF: AFF aff = new AFF(); Name = aff.Name; Description = aff.Description; Fields = aff.Fields; break; case Segments.AIG: AIG aig = new AIG(); Name = aig.Name; Description = aig.Description; Fields = aig.Fields; break; case Segments.AIL: AIL ail = new AIL(); Name = ail.Name; Description = ail.Description; Fields = ail.Fields; break; case Segments.AIP: AIP aip = new AIP(); Name = aip.Name; Description = aip.Description; Fields = aip.Fields; break; case Segments.AIS: AIS ais = new AIS(); Name = ais.Name; Description = ais.Description; Fields = ais.Fields; break; case Segments.AL1: AL1 al1 = new AL1(); Name = al1.Name; Description = al1.Description; Fields = al1.Fields; break; case Segments.APR: APR apr = new APR(); Name = apr.Name; Description = apr.Description; Fields = apr.Fields; break; case Segments.ARQ: ARQ arq = new ARQ(); Name = arq.Name; Description = arq.Description; Fields = arq.Fields; break; case Segments.AUT: AUT aut = new AUT(); Name = aut.Name; Description = aut.Description; Fields = aut.Fields; break; case Segments.BHS: BHS bhs = new BHS(); Name = bhs.Name; Description = bhs.Description; Fields = bhs.Fields; break; case Segments.BLC: BLC blc = new BLC(); Name = blc.Name; Description = blc.Description; Fields = blc.Fields; break; case Segments.BLG: BLG blg = new BLG(); Name = blg.Name; Description = blg.Description; Fields = blg.Fields; break; case Segments.BPO: BPO bpo = new BPO(); Name = bpo.Name; Description = bpo.Description; Fields = bpo.Fields; break; case Segments.BPX: BPX bpx = new BPX(); Name = bpx.Name; Description = bpx.Description; Fields = bpx.Fields; break; case Segments.BTS: BTS bts = new BTS(); Name = bts.Name; Description = bts.Description; Fields = bts.Fields; break; case Segments.BTX: BTX btx = new BTX(); Name = btx.Name; Description = btx.Description; Fields = btx.Fields; break; case Segments.CDM: CDM cdm = new CDM(); Name = cdm.Name; Description = cdm.Description; Fields = cdm.Fields; break; case Segments.CER: CER cer = new CER(); Name = cer.Name; Description = cer.Description; Fields = cer.Fields; break; case Segments.CM0: CM0 cm0 = new CM0(); Name = cm0.Name; Description = cm0.Description; Fields = cm0.Fields; break; case Segments.CM1: CM1 cm1 = new CM1(); Name = cm1.Name; Description = cm1.Description; Fields = cm1.Fields; break; case Segments.CM2: CM2 cm2 = new CM2(); Name = cm2.Name; Description = cm2.Description; Fields = cm2.Fields; break; case Segments.CNS: CNS cns = new CNS(); Name = cns.Name; Description = cns.Description; Fields = cns.Fields; break; case Segments.CON: CON con = new CON(); Name = con.Name; Description = con.Description; Fields = con.Fields; break; case Segments.CSP: CSP csp = new CSP(); Name = csp.Name; Description = csp.Description; Fields = csp.Fields; break; case Segments.CSR: CSR csr = new CSR(); Name = csr.Name; Description = csr.Description; Fields = csr.Fields; break; case Segments.CSS: CSS css = new CSS(); Name = css.Name; Description = css.Description; Fields = css.Fields; break; case Segments.CTD: CTD ctd = new CTD(); Name = ctd.Name; Description = ctd.Description; Fields = ctd.Fields; break; case Segments.CTI: CTI cti = new CTI(); Name = cti.Name; Description = cti.Description; Fields = cti.Fields; break; case Segments.DB1: DB1 db1 = new DB1(); Name = db1.Name; Description = db1.Description; Fields = db1.Fields; break; case Segments.DG1: DG1 dg1 = new DG1(); Name = dg1.Name; Description = dg1.Description; Fields = dg1.Fields; break; case Segments.DRG: DRG drg = new DRG(); Name = drg.Name; Description = drg.Description; Fields = drg.Fields; break; case Segments.DSC: DSC dsc = new DSC(); Name = dsc.Name; Description = dsc.Description; Fields = dsc.Fields; break; case Segments.DSP: DSP dsp = new DSP(); Name = dsp.Name; Description = dsp.Description; Fields = dsp.Fields; break; case Segments.ECD: ECD ecd = new ECD(); Name = ecd.Name; Description = ecd.Description; Fields = ecd.Fields; break; case Segments.ECR: ECR ecr = new ECR(); Name = ecr.Name; Description = ecr.Description; Fields = ecr.Fields; break; case Segments.EDU: EDU edu = new EDU(); Name = edu.Name; Description = edu.Description; Fields = edu.Fields; break; case Segments.EQL: EQL eql = new EQL(); Name = eql.Name; Description = eql.Description; Fields = eql.Fields; break; case Segments.EQP: EQP eqp = new EQP(); Name = eqp.Name; Description = eqp.Description; Fields = eqp.Fields; break; case Segments.EQU: EQU equ = new EQU(); Name = equ.Name; Description = equ.Description; Fields = equ.Fields; break; case Segments.ERQ: ERQ erq = new ERQ(); Name = erq.Name; Description = erq.Description; Fields = erq.Fields; break; case Segments.ERR: ERR err = new ERR(); Name = err.Name; Description = err.Description; Fields = err.Fields; break; case Segments.EVN: EVN evn = new EVN(); Name = evn.Name; Description = evn.Description; Fields = evn.Fields; break; case Segments.FAC: FAC fac = new FAC(); Name = fac.Name; Description = fac.Description; Fields = fac.Fields; break; case Segments.FHS: FHS fhs = new FHS(); Name = fhs.Name; Description = fhs.Description; Fields = fhs.Fields; break; case Segments.FT1: FT1 ft1 = new FT1(); Name = ft1.Name; Description = ft1.Description; Fields = ft1.Fields; break; case Segments.FTS: FTS fts = new FTS(); Name = fts.Name; Description = fts.Description; Fields = fts.Fields; break; case Segments.GOL: GOL gol = new GOL(); Name = gol.Name; Description = gol.Description; Fields = gol.Fields; break; case Segments.GP1: GP1 gp1 = new GP1(); Name = gp1.Name; Description = gp1.Description; Fields = gp1.Fields; break; case Segments.GP2: GP2 gp2 = new GP2(); Name = gp2.Name; Description = gp2.Description; Fields = gp2.Fields; break; case Segments.GT1: GT1 gt1 = new GT1(); Name = gt1.Name; Description = gt1.Description; Fields = gt1.Fields; break; case Segments.IAM: IAM iam = new IAM(); Name = iam.Name; Description = iam.Description; Fields = iam.Fields; break; case Segments.IIM: IIM iim = new IIM(); Name = iim.Name; Description = iim.Description; Fields = iim.Fields; break; case Segments.IN1: IN1 in1 = new IN1(); Name = in1.Name; Description = in1.Description; Fields = in1.Fields; break; case Segments.IN2: IN2 in2 = new IN2(); Name = in2.Name; Description = in2.Description; Fields = in2.Fields; break; case Segments.IN3: IN3 in3 = new IN3(); Name = in3.Name; Description = in3.Description; Fields = in3.Fields; break; case Segments.INV: INV inv = new INV(); Name = inv.Name; Description = inv.Description; Fields = inv.Fields; break; case Segments.IPC: IPC ipc = new IPC(); Name = ipc.Name; Description = ipc.Description; Fields = ipc.Fields; break; case Segments.ISD: ISD isd = new ISD(); Name = isd.Name; Description = isd.Description; Fields = isd.Fields; break; case Segments.LAN: LAN lan = new LAN(); Name = lan.Name; Description = lan.Description; Fields = lan.Fields; break; case Segments.LCC: LCC lcc = new LCC(); Name = lcc.Name; Description = lcc.Description; Fields = lcc.Fields; break; case Segments.LCH: LCH lch = new LCH(); Name = lch.Name; Description = lch.Description; Fields = lch.Fields; break; case Segments.LDP: LDP ldp = new LDP(); Name = ldp.Name; Description = ldp.Description; Fields = ldp.Fields; break; case Segments.LOC: LOC loc = new LOC(); Name = loc.Name; Description = loc.Description; Fields = loc.Fields; break; case Segments.LRL: LRL lrl = new LRL(); Name = lrl.Name; Description = lrl.Description; Fields = lrl.Fields; break; case Segments.MFA: MFA mfa = new MFA(); Name = mfa.Name; Description = mfa.Description; Fields = mfa.Fields; break; case Segments.MFE: MFE mfe = new MFE(); Name = mfe.Name; Description = mfe.Description; Fields = mfe.Fields; break; case Segments.MFI: MFI mfi = new MFI(); Name = mfi.Name; Description = mfi.Description; Fields = mfi.Fields; break; case Segments.MRG: MRG mrg = new MRG(); Name = mrg.Name; Description = mrg.Description; Fields = mrg.Fields; break; case Segments.MSA: MSA msa = new MSA(); Name = msa.Name; Description = msa.Description; Fields = msa.Fields; break; case Segments.MSH: MSH msh = new MSH(); Name = msh.Name; Description = msh.Description; Fields = msh.Fields; break; case Segments.NCK: NCK nck = new NCK(); Name = nck.Name; Description = nck.Description; Fields = nck.Fields; break; case Segments.NDS: NDS nds = new NDS(); Name = nds.Name; Description = nds.Description; Fields = nds.Fields; break; case Segments.NK1: NK1 nk1 = new NK1(); Name = nk1.Name; Description = nk1.Description; Fields = nk1.Fields; break; case Segments.NPU: NPU npu = new NPU(); Name = npu.Name; Description = npu.Description; Fields = npu.Fields; break; case Segments.NSC: NSC nsc = new NSC(); Name = nsc.Name; Description = nsc.Description; Fields = nsc.Fields; break; case Segments.NST: NST nst = new NST(); Name = nst.Name; Description = nst.Description; Fields = nst.Fields; break; case Segments.NTE: NTE nte = new NTE(); Name = nte.Name; Description = nte.Description; Fields = nte.Fields; break; case Segments.OBR: OBR obr = new OBR(); Name = obr.Name; Description = obr.Description; Fields = obr.Fields; break; case Segments.OBX: OBX obx = new OBX(); Name = obx.Name; Description = obx.Description; Fields = obx.Fields; break; case Segments.ODS: ODS ods = new ODS(); Name = ods.Name; Description = ods.Description; Fields = ods.Fields; break; case Segments.ODT: ODT odt = new ODT(); Name = odt.Name; Description = odt.Description; Fields = odt.Fields; break; case Segments.OM1: OM1 om1 = new OM1(); Name = om1.Name; Description = om1.Description; Fields = om1.Fields; break; case Segments.OM2: OM2 om2 = new OM2(); Name = om2.Name; Description = om2.Description; Fields = om2.Fields; break; case Segments.OM3: OM3 om3 = new OM3(); Name = om3.Name; Description = om3.Description; Fields = om3.Fields; break; case Segments.OM4: OM4 om4 = new OM4(); Name = om4.Name; Description = om4.Description; Fields = om4.Fields; break; case Segments.OM5: OM5 om5 = new OM5(); Name = om5.Name; Description = om5.Description; Fields = om5.Fields; break; case Segments.OM6: OM6 om6 = new OM6(); Name = om6.Name; Description = om6.Description; Fields = om6.Fields; break; case Segments.OM7: OM7 om7 = new OM7(); Name = om7.Name; Description = om7.Description; Fields = om7.Fields; break; case Segments.ORC: ORC orc = new ORC(); Name = orc.Name; Description = orc.Description; Fields = orc.Fields; break; case Segments.ORG: ORG org = new ORG(); Name = org.Name; Description = org.Description; Fields = org.Fields; break; case Segments.OVR: OVR ovr = new OVR(); Name = ovr.Name; Description = ovr.Description; Fields = ovr.Fields; break; case Segments.PCR: PCR pcr = new PCR(); Name = pcr.Name; Description = pcr.Description; Fields = pcr.Fields; break; case Segments.PD1: PD1 pd1 = new PD1(); Name = pd1.Name; Description = pd1.Description; Fields = pd1.Fields; break; case Segments.PDA: PDA pda = new PDA(); Name = pda.Name; Description = pda.Description; Fields = pda.Fields; break; case Segments.PDC: PDC pdc = new PDC(); Name = pdc.Name; Description = pdc.Description; Fields = pdc.Fields; break; case Segments.PEO: PEO peo = new PEO(); Name = peo.Name; Description = peo.Description; Fields = peo.Fields; break; case Segments.PES: PES pes = new PES(); Name = pes.Name; Description = pes.Description; Fields = pes.Fields; break; case Segments.PID: PID pid = new PID(); Name = pid.Name; Description = pid.Description; Fields = pid.Fields; break; case Segments.PR1: PR1 pr1 = new PR1(); Name = pr1.Name; Description = pr1.Description; Fields = pr1.Fields; break; case Segments.PRA: PRA pra = new PRA(); Name = pra.Name; Description = pra.Description; Fields = pra.Fields; break; case Segments.PRB: PRB prb = new PRB(); Name = prb.Name; Description = prb.Description; Fields = prb.Fields; break; case Segments.PRC: PRC prc = new PRC(); Name = prc.Name; Description = prc.Description; Fields = prc.Fields; break; case Segments.PRD: PRD prd = new PRD(); Name = prd.Name; Description = prd.Description; Fields = prd.Fields; break; case Segments.PSH: PSH psh = new PSH(); Name = psh.Name; Description = psh.Description; Fields = psh.Fields; break; case Segments.PTH: PTH pth = new PTH(); Name = pth.Name; Description = pth.Description; Fields = pth.Fields; break; case Segments.PV1: PV1 pv1 = new PV1(); Name = pv1.Name; Description = pv1.Description; Fields = pv1.Fields; break; case Segments.PV2: PV2 pv2 = new PV2(); Name = pv2.Name; Description = pv2.Description; Fields = pv2.Fields; break; case Segments.QAK: QAK qak = new QAK(); Name = qak.Name; Description = qak.Description; Fields = qak.Fields; break; case Segments.QID: QID qid = new QID(); Name = qid.Name; Description = qid.Description; Fields = qid.Fields; break; case Segments.QPD: QPD qpd = new QPD(); Name = qpd.Name; Description = qpd.Description; Fields = qpd.Fields; break; case Segments.QRD: QRD qrd = new QRD(); Name = qrd.Name; Description = qrd.Description; Fields = qrd.Fields; break; case Segments.QRF: QRF qrf = new QRF(); Name = qrf.Name; Description = qrf.Description; Fields = qrf.Fields; break; case Segments.QRI: QRI qri = new QRI(); Name = qri.Name; Description = qri.Description; Fields = qri.Fields; break; case Segments.RCP: RCP rcp = new RCP(); Name = rcp.Name; Description = rcp.Description; Fields = rcp.Fields; break; case Segments.RDF: RDF rdf = new RDF(); Name = rdf.Name; Description = rdf.Description; Fields = rdf.Fields; break; case Segments.RF1: RF1 rf1 = new RF1(); Name = rf1.Name; Description = rf1.Description; Fields = rf1.Fields; break; case Segments.RGS: RGS rgs = new RGS(); Name = rgs.Name; Description = rgs.Description; Fields = rgs.Fields; break; case Segments.RMI: RMI rmi = new RMI(); Name = rmi.Name; Description = rmi.Description; Fields = rmi.Fields; break; case Segments.ROL: ROL rol = new ROL(); Name = rol.Name; Description = rol.Description; Fields = rol.Fields; break; case Segments.RQ1: RQ1 rq1 = new RQ1(); Name = rq1.Name; Description = rq1.Description; Fields = rq1.Fields; break; case Segments.RQD: RQD rqd = new RQD(); Name = rqd.Name; Description = rqd.Description; Fields = rqd.Fields; break; case Segments.RXA: RXA rxa = new RXA(); Name = rxa.Name; Description = rxa.Description; Fields = rxa.Fields; break; case Segments.RXC: RXC rxc = new RXC(); Name = rxc.Name; Description = rxc.Description; Fields = rxc.Fields; break; case Segments.RXD: RXD rxd = new RXD(); Name = rxd.Name; Description = rxd.Description; Fields = rxd.Fields; break; case Segments.RXE: RXE rxe = new RXE(); Name = rxe.Name; Description = rxe.Description; Fields = rxe.Fields; break; case Segments.RXG: RXG rxg = new RXG(); Name = rxg.Name; Description = rxg.Description; Fields = rxg.Fields; break; case Segments.RXO: RXO rxo = new RXO(); Name = rxo.Name; Description = rxo.Description; Fields = rxo.Fields; break; case Segments.RXR: RXR rxr = new RXR(); Name = rxr.Name; Description = rxr.Description; Fields = rxr.Fields; break; case Segments.SAC: SAC sac = new SAC(); Name = sac.Name; Description = sac.Description; Fields = sac.Fields; break; case Segments.SCH: SCH sch = new SCH(); Name = sch.Name; Description = sch.Description; Fields = sch.Fields; break; case Segments.SFT: SFT sft = new SFT(); Name = sft.Name; Description = sft.Description; Fields = sft.Fields; break; case Segments.SID: SID sid = new SID(); Name = sid.Name; Description = sid.Description; Fields = sid.Fields; break; case Segments.SPM: SPM spm = new SPM(); Name = spm.Name; Description = spm.Description; Fields = spm.Fields; break; case Segments.SPR: SPR spr = new SPR(); Name = spr.Name; Description = spr.Description; Fields = spr.Fields; break; case Segments.STF: STF stf = new STF(); Name = stf.Name; Description = stf.Description; Fields = stf.Fields; break; case Segments.TCC: TCC tcc = new TCC(); Name = tcc.Name; Description = tcc.Description; Fields = tcc.Fields; break; case Segments.TCD: TCD tcd = new TCD(); Name = tcd.Name; Description = tcd.Description; Fields = tcd.Fields; break; case Segments.TQ1: TQ1 tq1 = new TQ1(); Name = tq1.Name; Description = tq1.Description; Fields = tq1.Fields; break; case Segments.TQ2: TQ2 tq2 = new TQ2(); Name = tq2.Name; Description = tq2.Description; Fields = tq2.Fields; break; case Segments.TXA: TXA txa = new TXA(); Name = txa.Name; Description = txa.Description; Fields = txa.Fields; break; case Segments.UB1: UB1 ub1 = new UB1(); Name = ub1.Name; Description = ub1.Description; Fields = ub1.Fields; break; case Segments.UB2: UB2 ub2 = new UB2(); Name = ub2.Name; Description = ub2.Description; Fields = ub2.Fields; break; case Segments.URD: URD urd = new URD(); Name = urd.Name; Description = urd.Description; Fields = urd.Fields; break; case Segments.URS: URS urs = new URS(); Name = urs.Name; Description = urs.Description; Fields = urs.Fields; break; case Segments.VAR: VAR var = new VAR(); Name = var.Name; Description = var.Description; Fields = var.Fields; break; case Segments.VTQ: VTQ vtq = new VTQ(); Name = vtq.Name; Description = vtq.Description; Fields = vtq.Fields; break; } }
public Vector3Variable(string name, CSP p, BoundingBox b) : this(name, p, b.X, b.Y, b.Z) { }
public Vector3Variable(string name, CSP p, double x, double y, double z) : this(name, p, new Interval(x), new Interval(y), new Interval(z)) { }
public void EvenPowerZeroCrossingATest() { var p = new CSP(); var a = new FloatVariable("a", p, -3, 3); var power = a ^ 2; power.MustEqual(4f); p.TestConsistency(); Assert.AreEqual(new Interval(-2,2), a.Value); }