Ejemplo n.º 1
0
 def run(self):
   model = mp_model.build(self._args.file)
   decomposer = decomposers.get_instance_of(self._args.decomposer_id, model)
   try:
     decomposer.decompose()
   except Exception, e:
     logging.exception('Cannot decompose the model.')
     return
Ejemplo n.º 2
0
 def __init__(self, model, optimization_parameters, pipeline):
   super(LocalEliminationDriver, self).__init__()
   if not model.is_binary():
     raise TypeError("Optimization can be applied only to binary integer "
                     "linear programming problems.")
   self._pipeline = pipeline
   self._optimization_params = optimization_parameters
   self._driver_params = optimization_parameters.driver.local_elimination_driver_parameters
   self._decomposer = decomposers.get_instance_of(self._driver_params.decomposer, model)
   logging.info("Decomposer: %s" % self._decomposer.__class__.__name__)
   self._solution_table = solution_tables.get_instance_of(self._driver_params.solution_table)
   if not self._solution_table:
     logging.info("Cannot create solution table: %d", self._driver_params.solution_table)
     return
   logging.info("Relaxation backend solvers are %s", self._driver_params.relaxation_backend_solvers)
   self._solver_id_stack = list(self._driver_params.relaxation_backend_solvers)
   self._solver_id_stack.append(optimization_parameters.driver.default_backend_solver)
   self._active_contexts = collections.OrderedDict()
   self._frozen_contexts = {}