public void AverageConstraintTest() { var p = new Problem(nameof(AverageConstraintTest)); var dom = new FloatDomain("unit", -1, 1); var vars = new FloatVariable[10]; for (int i = 0; i < vars.Length; i++) { vars[i] = (FloatVariable)dom.Instantiate("x" + i); } var average = FloatVariable.Average(vars); for (int i = 0; i < 100; i++) { var s = p.Solve(); Console.WriteLine(s.Model); var avg = vars.Select(v => v.Value(s)).Average(); Assert.IsTrue(Math.Abs(average.Value(s) - avg) < 0.00001f); } }