예제 #1
0
        static void Main(string[] args)
        {
            Class1.Test();

            var       qpProblem = new QpGeneratorSimple().Generate(200);
            IQpSolver solver    = new QpSolver();
            QpReport  report    = solver.Solve(qpProblem);

            Console.WriteLine(report.ElapsedTime);
            Console.ReadLine();
        }
예제 #2
0
        public void QpInfeasible()
        {
            // Arrange
            var qpProblem = new QpGeneratorInfeasible().Generate(n);

            // Act
            IQpSolver solver = new QpSolver();
            QpReport  report = solver.Solve(qpProblem);

            // Assert
            Assert.AreEqual(TerminationType.Infeasible, report.Type);
        }
예제 #3
0
        public void ProfileMatchingSpreadsheet()
        {
            // Arrange
            var problem = new ProfileMatcherSpreadsheet().Generate(1);

            IQpProblem qpProblem = new ProfileMatchingQpConverter(
                ProfileMatchingMetric.CumulativeSumsquares).Convert(problem);

            // Act
            IQpSolver solver = new QpSolver();
            QpReport  report = solver.Solve(qpProblem);

            SaveArrayAsCSV(report.X, @"C:\Users\Alex\Documents\TEMP\blah.csv");
        }
예제 #4
0
        public void ProfileMatchingInfeasible()
        {
            // Arrange
            var problem = new ProfileMatcherInfeasible().Generate();

            IQpProblem qpProblem = new ProfileMatchingQpConverter(
                ProfileMatchingMetric.CumulativeSumsquares).Convert(problem);

            // Act
            IQpSolver solver = new QpSolver();
            QpReport  report = solver.Solve(qpProblem);

            // Assert
            Assert.AreEqual(TerminationType.Infeasible, report.Type);
        }
예제 #5
0
        public void QpSimple()
        {
            // Arrange
            var qpProblem = new QpGeneratorSimple().Generate(n);

            // Act
            IQpSolver solver = new QpSolver();
            QpReport  report = solver.Solve(qpProblem);

            // Assert
            var builder = Vector <double> .Build;
            var check   = builder.DenseOfArray(report.X) + builder.DenseOfArray(qpProblem.C);

            Assert.IsTrue(check.Norm(2) < (1e-8 * n));
        }
예제 #6
0
        public void ProfileMatchingUnconstrained()
        {
            // Arrange
            var problem = new ProfileMatcherUnconstrained().Generate();

            IQpProblem qpProblem = new ProfileMatchingQpConverter(
                ProfileMatchingMetric.CumulativeSumsquares).Convert(problem);

            // Act
            IQpSolver solver = new QpSolver();
            QpReport  report = solver.Solve(qpProblem);

            // Assert
            Assert.AreEqual(report.X[0], 2, Epsilon);
            Assert.AreEqual(report.X[1], 1, Epsilon);
            Assert.AreEqual(report.X[2], 3, Epsilon);
        }
예제 #7
0
        public void ProfileMatchingEquality()
        {
            // Arrange
            var problem = new ProfileMatcherEquality().Generate();

            IQpProblem qpProblem = new ProfileMatchingQpConverter(
                ProfileMatchingMetric.CumulativeSumsquares).Convert(problem);

            // Act
            IQpSolver solver = new QpSolver();
            QpReport  report = solver.Solve(qpProblem);

            // Assert
            Assert.AreEqual(report.X[0], 1.92682926808697, Epsilon);
            Assert.AreEqual(report.X[1], 1.4390243902732891, Epsilon);
            Assert.AreEqual(report.X[2], 2, Epsilon);
        }
예제 #8
0
        public void ProfileMatchingSimple()
        {
            // Arrange
            var problem = new ProfileMatcherSimple().Generate();

            IQpProblem qpProblem = new ProfileMatchingQpConverter(
                ProfileMatchingMetric.CumulativeSumsquares).Convert(problem);

            // Act
            IQpSolver solver = new QpSolver();
            QpReport  report = solver.Solve(qpProblem);

            // Assert
            Assert.AreEqual(report.X[0], 1.95238095238094, Epsilon);
            Assert.AreEqual(report.X[1], 1.42857142857143, Epsilon);
            Assert.AreEqual(report.X[2], 2, Epsilon);
        }