public void EvenPowerNegativeTest() { var p = new CSP(); var a = new FloatVariable("a", p, -3, 0); var power = a ^ 2; a.MustEqual(-2f); p.TestConsistency(); AssertUnique(power, 4f); }
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); }
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 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); }
public void QuotientBTest() { var p = new CSP(); var a = new FloatVariable("a", p, 0, 3); var b = new FloatVariable("b", p, 0, 3); var quotient = a / b; a.MustEqual(0.5f); quotient.MustEqual(0.25f); p.TestConsistency(); AssertUnique(b, 2f); }
public void ProductBTest() { 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); product.MustEqual(0.25f); p.TestConsistency(); AssertUnique(b, 0.5f); }
public void DifferenceBTest() { 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); difference.MustEqual(0.25f); p.TestConsistency(); AssertUnique(b, 0.25f); }
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 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 EvenPowerNegativeTest() { var p = new CSP(); var a = new FloatVariable("a", p, -3, 0); var power = a ^ 2; a.MustEqual(-2f); p.TestConsistency(); AssertUnique(power, 4f); }
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); }
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 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 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); }