Exemplo n.º 1
0
    def testInstanceData(self):
        """
        test some fake instances
        """

        d = pd.DataFrame(
            [  #  ProblemName PrimalBound DualBound     Objsense           SolverStatus       Status
                (inf_good, None, None, osc.MINIMIZE, ssc.Infeasible, psc.Ok),
                (inf_bad, 5, 5, osc.MINIMIZE, ssc.Optimal,
                 psc.FailSolOnInfeasibleInstance),
                (inf_time, None, None, osc.MINIMIZE, ssc.TimeLimit,
                 psc.TimeLimit),
                (feas_good, 3, None, osc.MAXIMIZE, ssc.MemoryLimit,
                 psc.MemoryLimit),
                (feas_bad, 3, None, osc.MAXIMIZE, ssc.Infeasible,
                 psc.FailDualBound),
                (opt_good, 10, 10, osc.MAXIMIZE, ssc.Optimal, psc.Ok),
                (opt_bad, 9, 9, osc.MAXIMIZE, ssc.Optimal, psc.FailDualBound),
                (opt_tol, 10 - 1e-5, 10 - 1e-5, osc.MAXIMIZE, ssc.Optimal,
                 psc.Ok),
                (best_good, 105, 85, osc.MINIMIZE, ssc.NodeLimit,
                 psc.NodeLimit),
                (best_dbad, 105, 103, osc.MINIMIZE, ssc.NodeLimit,
                 psc.FailDualBound),
                (best_pbad, 85, 85, osc.MINIMIZE, ssc.Optimal,
                 psc.FailObjectiveValue),
                (opt_abort, None, None, osc.MINIMIZE, ssc.Crashed,
                 psc.FailAbort),
                (opt_readerror, None, None, osc.MINIMIZE, ssc.Readerror,
                 psc.FailReaderror),
            ],
            columns=[
                Key.ProblemName, Key.PrimalBound, Key.DualBound,
                Key.ObjectiveSense, Key.SolverStatus, "Status"
            ])

        v = Validation()
        v.referencedict = {
            inf_good: (Validation.__infeas__, None),
            inf_bad: (Validation.__infeas__, None),
            inf_time: (Validation.__infeas__, None),
            feas_good: (Validation.__feas__, Validation.__feas__),
            feas_bad: (Validation.__feas__, Validation.__feas__),
            opt_good: (10, 10),
            opt_bad: (10, 10),
            opt_tol: (10, 10),
            best_good: (100, 90),
            best_pbad: (100, 90),
            best_dbad: (100, 90),
            opt_abort: (1, 1),
            opt_readerror: (1, 1)
        }

        self.compareValidationStatus(d, v)
Exemplo n.º 2
0
    def testInconsistencydetection(self):
        """test if inconsistent primal and dual bounds are detected well.
        """

        d = pd.DataFrame([
            (opt_good, 100, 90, osc.MINIMIZE, ssc.TimeLimit, psc.TimeLimit),
            (opt_good, 95, 85, osc.MINIMIZE, ssc.TimeLimit, psc.TimeLimit),
            (opt_bad, 100, 90, osc.MINIMIZE, ssc.TimeLimit,
             psc.FailInconsistent),
            (opt_bad, 89, 89, osc.MINIMIZE, ssc.Optimal, psc.FailInconsistent),
            (part_inconsistent, 12, 12, osc.MINIMIZE, ssc.Optimal,
             psc.FailDualBound),
            (part_inconsistent, 10, 10, osc.MINIMIZE, ssc.Optimal,
             psc.FailInconsistent),
            (part_inconsistent, 9, 9, osc.MINIMIZE, ssc.Optimal,
             psc.FailInconsistent),
            (both_infeasible, numpy.nan, numpy.nan, osc.MAXIMIZE,
             ssc.Infeasible, psc.Ok),
            (both_infeasible, numpy.nan, numpy.nan, osc.MAXIMIZE,
             ssc.Infeasible, psc.Ok),
            (one_says_infeasible, numpy.nan, numpy.nan, osc.MINIMIZE,
             ssc.Infeasible, psc.FailInconsistent),
            (one_says_infeasible, 1, 1, osc.MINIMIZE, ssc.Optimal,
             psc.FailInconsistent),
            (one_says_infeasible, 3, 0, osc.MINIMIZE, ssc.TimeLimit,
             psc.FailInconsistent)
        ],
                         columns=[
                             Key.ProblemName, Key.PrimalBound, Key.DualBound,
                             Key.ObjectiveSense, Key.SolverStatus, "Status"
                         ])

        v = Validation()

        v.referencedict = {part_inconsistent: (10, 0)}

        v.collectInconsistencies(d)

        self.assertNotIn(opt_good, v.inconsistentset,
                         "{} wrongly appears as inconsistent".format(opt_good))
        self.assertNotIn(
            both_infeasible, v.inconsistentset,
            "{} wrongly appears as inconsistent".format(both_infeasible))
        self.assertIn(opt_bad, v.inconsistentset,
                      "{} should be inconsistent".format(opt_bad))
        self.assertIn(part_inconsistent, v.inconsistentset,
                      "{} should be inconsistent".format(part_inconsistent))
        self.assertIn(one_says_infeasible, v.inconsistentset,
                      "{} should be inconsistent".format(one_says_infeasible))

        self.compareValidationStatus(d, v)