Esempio n. 1
0
    def runtest(self):
        # Check solution
        solution: Dict[str, Any] = self.result["solution"]
        model = Model(self.base_dir / self.result["model"])
        model["mzn_ignore_symmetry_breaking_constraints"] = True
        model["mzn_ignore_redundant_constraints"] = True
        if "data_file" in self.result and len(self.result["data_file"]) > 0:
            model.add_file(self.base_dir / self.result["data_file"])
        status = Status[self.result["status"]]
        assert check_solution(model, solution, status,
                              self.checker), "Incorrect solution"

        # Record that the problem is satisfiable for use in check_statuses
        self.user_properties.append(("sat", (self.key, True)))

        # Record objective for use in check_statuses
        if "objective" in solution:
            self.user_properties.append(
                ("objective", (self.key, solution["objective"])))
 def test_check_specific(self):
     assert self.instance.method == Method.SATISFY
     result = self.instance.solve(nr_solutions=5)
     assert check_solution(self.instance, result, self.other_solver, [1, 2])
 def test_check_all(self):
     assert self.instance.method == Method.SATISFY
     result = self.instance.solve(all_solutions=True)
     assert check_solution(self.instance, result, self.other_solver,
                           range(len(result.solution)))
 def test_incorrect(self):
     assert self.instance.method == Method.SATISFY
     result = self.instance.solve()
     result.solution = self.instance.output_type(x=[2, 1])
     assert not check_solution(self.instance, result, self.other_solver)
 def test_correct(self):
     assert self.instance.method == Method.SATISFY
     result = self.instance.solve()
     assert check_solution(self.instance, result, self.other_solver)
Esempio n. 6
0
 def test_dict(self):
     assert check_solution(self.instance, {"x": [5, 6]}, Status.SATISFIED,
                           self.other_solver)