How to use the pyscipopt.SCIP_RESULT.FEASIBLE function in PySCIPOpt

To help you get started, we’ve selected a few PySCIPOpt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SCIP-Interfaces / PySCIPOpt / tests / test_customizedbenders.py View on Github external
def benderscutexec(self, solution, probnumber, enfotype):
      subprob = self.model.getBendersSubproblem(probnumber, benders=self.benders)
      membersubprob = self.benders.subprob

      # checking whether the subproblem is already optimal, i.e. whether a cut
      # needs to be generated
      if self.model.checkBendersSubproblemOptimality(solution, probnumber,
            benders=self.benders):
         return {"result" : SCIP_RESULT.FEASIBLE}

      # testing whether the dual multipliers can be found for the retrieved
      # subproblem model. If the constraints don't exist, then the subproblem
      # model is not correct.
      # Also checking whether the dual multiplier is the same between the
      # member subproblem and the retrieved subproblem`
      lhs = 0
      for i in self.I:
         subprobcons = self.benders.demand[i]
         try:
            dualmult = subprob.getDualMultiplier(subprobcons)
            lhs += dualmult*self.d[i]
         except:
            print("Subproblem constraint <%d> does not exist in the "\
                  "subproblem."%subprobcons.name)
            assert False
github SCIP-Interfaces / PySCIPOpt / tests / test_customizedbenders.py View on Github external
def benderssolvesubconvex(self, solution, probnumber, onlyconvex):
        self.model.setupBendersSubproblem(probnumber, self, solution)
        self.subprob.solveProbingLP()
        subprob = self.model.getBendersSubproblem(probnumber, self)
        assert self.subprob.getObjVal() == subprob.getObjVal()

        result_dict = {}

        objective = subprob.infinity()
        result = SCIP_RESULT.DIDNOTRUN
        lpsolstat = self.subprob.getLPSolstat()
        if lpsolstat == SCIP_LPSOLSTAT.OPTIMAL:
           objective = self.subprob.getObjVal()
           result = SCIP_RESULT.FEASIBLE
        elif lpsolstat == SCIP_LPSOLSTAT.INFEASIBLE:
           objective = self.subprob.infinity()
           result = SCIP_RESULT.INFEASIBLE
        elif lpsolstat == SCIP_LPSOLSTAT.UNBOUNDEDRAY:
           objective = self.subprob.infinity()
           result = SCIP_RESULT.UNBOUNDED


        result_dict["objective"] = objective
        result_dict["result"] = result

        return result_dict
github SCIP-Interfaces / PySCIPOpt / tests / test_alldiff.py View on Github external
def consenfolp(self, constraints, n_useful_conss, sol_infeasible):
        for cons in constraints:
            if not self.is_cons_feasible(cons):
                # TODO: suggest some value to branch on
                return {"result": SCIP_RESULT.INFEASIBLE}
        return {"result": SCIP_RESULT.FEASIBLE}
github SCIP-Interfaces / PySCIPOpt / tests / test_customizedbenders.py View on Github external
def benderssolvesubconvex(self, solution, probnumber, onlyconvex):
        self.model.setupBendersSubproblem(probnumber, self, solution)
        self.subprob.solveProbingLP()
        subprob = self.model.getBendersSubproblem(probnumber, self)
        assert self.subprob.getObjVal() == subprob.getObjVal()

        result_dict = {}

        objective = subprob.infinity()
        result = SCIP_RESULT.DIDNOTRUN
        lpsolstat = self.subprob.getLPSolstat()
        if lpsolstat == SCIP_LPSOLSTAT.OPTIMAL:
           objective = self.subprob.getObjVal()
           result = SCIP_RESULT.FEASIBLE
        elif lpsolstat == SCIP_LPSOLSTAT.INFEASIBLE:
           objective = self.subprob.infinity()
           result = SCIP_RESULT.INFEASIBLE
        elif lpsolstat == SCIP_LPSOLSTAT.UNBOUNDEDRAY:
           objective = self.subprob.infinity()
           result = SCIP_RESULT.UNBOUNDED


        result_dict["objective"] = objective
        result_dict["result"] = result

        return result_dict
github SCIP-Interfaces / PySCIPOpt / tests / test_customizedbenders.py View on Github external
subprob = self.model.getBendersSubproblem(probnumber, benders=self.benders)
      membersubprob = self.benders.subprob

      print("executing benderscutexec")

      # checking whether the subproblem is already optimal, i.e. whether a cut
      # needs to be generated
      print("Subproblem stage:", subprob.getStage())
      print(solution)
      print(probnumber)
      print(self.benders)
      print(self.model.checkBendersSubproblemOptimality(solution, probnumber,
            benders=self.benders))
      if self.model.checkBendersSubproblemOptimality(solution, probnumber,
            benders=self.benders):
         return {"result" : SCIP_RESULT.FEASIBLE}

      # testing whether the dual multipliers can be found for the retrieved
      # subproblem model. If the constraints don't exist, then the subproblem
      # model is not correct.
      # Also checking whether the dual multiplier is the same between the
      # member subproblem and the retrieved subproblem`
      print("computing LHS of benders cut")
      lhs = 0
      for i in self.I:
         subprobcons = self.benders.demand[i]
         try:
            dualmult = subprob.getDualMultiplier(subprobcons)
            lhs += dualmult*self.d[i]
         except:
            print("Subproblem constraint <%d> does not exist in the "\
                  "subproblem."%subprobcons.name)
github SCIP-Interfaces / PySCIPOpt / tests / test_conshdlr.py View on Github external
def conscheck(self, constraints, solution, checkintegrality, checklprows, printreason, completely):
        calls.add("conscheck")
        for constraint in constraints:
            assert id(constraint) in ids
        return {"result": SCIP_RESULT.FEASIBLE}
github SCIP-Interfaces / PySCIPOpt / tests / test_tsp.py View on Github external
def conscheck(self, constraints, solution, check_integrality,
                  check_lp_rows, print_reason, completely, **results):
        if self.find_subtours(solution):
            return {"result": SCIP_RESULT.INFEASIBLE}
        else:
            return {"result": SCIP_RESULT.FEASIBLE}
github SCIP-Interfaces / PySCIPOpt / tests / test_coloring.py View on Github external
def conscheck(self, constraints, solution, checkintegrality, checklprows, printreason):
        entering()
        leaving()
        return {"result": SCIP_RESULT.FEASIBLE}
    def conslock(self, constraint, nlockspos, nlocksneg):
github SCIP-Interfaces / PySCIPOpt / examples / finished / lotsizing_lazy.py View on Github external
def consenfolp(self, constraints, nusefulconss, solinfeasible):
        if self.addcut(checkonly = False):
            return {"result": SCIP_RESULT.CONSADDED}
        else:
            return {"result": SCIP_RESULT.FEASIBLE}
github SCIP-Interfaces / PySCIPOpt / examples / unfinished / tsp_lazy.py View on Github external
def consenfolp(self, constraints, nusefulconss, solinfeasible):
        if self.findSubtours(checkonly = False, sol = None):
            return {"result": SCIP_RESULT.CONSADDED}
        else:
            return {"result": SCIP_RESULT.FEASIBLE}