Esempio n. 1
0
        public IntervalTester()
        {
            this.Tolerance = 1e-3;
            this.Attempts  = 5;

            var vars_1 = new[] { "x" };
            var vars_2 = new[] { "x", "y" };
            var vars_3 = new[] { "x", "y", "z" };

            RemoteFunction <Interval> f1 = new IntervalRemoteFunction(json: $"{TASKS_LOC}/Dummy/Dummy_1.json", port: 10001, field: "f");
            Dictionary <string, Tuple <double, double> > a1 = vars_1.ToDictionary(k => k, k => Tuple.Create(-10.0, 10.0));
            Dictionary <string, double> s1 = vars_1.ToDictionary(k => k, k => 0.0);

            RemoteFunction <Interval> f2 = new IntervalRemoteFunction(json: $"{TASKS_LOC}/Dummy/Dummy_2.json", port: 10002, field: "f");
            Dictionary <string, Tuple <double, double> > a2 = vars_2.ToDictionary(k => k, k => Tuple.Create(-10.0, 10.0));
            Dictionary <string, double> s2 = vars_2.ToDictionary(k => k, k => 0.0);

            RemoteFunction <Interval> f3 = new IntervalRemoteFunction(json: $"{TASKS_LOC}/Dummy/Dummy_3.json", port: 10003, field: "f");
            Dictionary <string, Tuple <double, double> > a3 = vars_3.ToDictionary(k => k, k => Tuple.Create(-10.0, 10.0));
            Dictionary <string, double> s3 = vars_3.ToDictionary(k => k, k => 0.0);

            this.TestFunctions = new[] { f1, f2, f3 };
            this.Areas         = new[] { a1, a2, a3 };
            this.Solutions     = new[] { s1, s2, s3 };
        }
Esempio n. 2
0
        public static void TestIntervalRemoteFunction()
        {
            var f = new IntervalRemoteFunction(json: $"{TASKS_LOC}/Dummy/Dummy_3.json", port: 10000, field: "f");

            f.Initialize();
            List <Interval> results = new List <Interval>();

            for (int i = 0; i < N; ++i)
            {
                var result = f.Calculate(new Dictionary <string, Interval>()
                {
                    { "x", new Interval(1, 2) },
                    { "y", new Interval(2, 3) },
                    { "z", new Interval(3, 4) }
                });
                results.Add(result);
            }

            f.Terminate();

            Assert.True(results.TrueForAll(_ => _.EqualsTo(new Interval(36, 70))));
        }