def new_engine(self, solver_agent, env, model, context=None): self._ensure_cplex_resolved(env) # compute a default engine and kwargs to use.. kwargs = {} if self._cplex_engine_type: # CPLEX ahs been resolved and has a non-None type # default is CPLEX if we have it default_engine_type = self._cplex_engine_type default_engine_name = 'cplex' elif has_credentials(context.solver.docloud): # default is docloud default_engine_type = DOcloudEngine default_engine_name = 'docloud' else: # no CPLEX, no credentials # model.trace("CPLEX DLL not found and model has no DOcplexcloud credentials. " # "Credentials are required at solve time") default_engine_type = NoSolveEngine default_engine_name = 'nosolve' if has_credentials(context.solver.docloud): kwargs['docloud_context'] = context.solver.docloud engine_type = self._get_engine_from_agent( agent=solver_agent, default_engine=default_engine_type, default_engine_name=default_engine_name) assert engine_type is not None # all engine types have a (model, kwargs) ctor. return engine_type(model, **kwargs)
def new_engine(self, agent, env, model, context=None): self._ensure_cplex_resolved(env) # compute a default engine and kwargs to use.. kwargs = {} if self._cplex_engine_type: # default is CPLEX if we have it default_engine_type = self._cplex_engine_type default_engine_name = 'cplex' else: # no CPLEX, no credentials default_engine_type = NoSolveEngine default_engine_name = 'nosolve' if has_credentials(context.solver.docloud): kwargs['docloud_context'] = context.solver.docloud if context is not None: kwargs['context'] = context engine_type = self._get_engine_type_from_agent(agent=agent, default_engine=default_engine_type, default_engine_name=default_engine_name) assert engine_type is not None try: return engine_type(model, **kwargs) except TypeError: docplex_fatal("agent: {0!s} failed to create instance from model, kwargs.", agent)
def __init__(self, docloud_context, log_output=None): """ Starts a connector which URL and authorization are stored in the specified context, along with other connection parameters The `docloud_context` refers to the context.solver.docloud node of a context. Args: log_output: The log output stream """ if docloud_context is None or not has_credentials(docloud_context): raise DOcloudConnectorException( "Please provide DOcplexcloud credentials") # store this for future usage self.docloud_context = docloud_context url = docloud_context.url auth = docloud_context.key self.logger = get_logger('DOcloudConnector', self.docloud_context.verbose) self.logger.info("DOcplexcloud connection using url = " + str(url) + " api_key = " + key_as_string(auth)) self.logger.info("DOcplexcloud SSL verification = " + str(docloud_context.verify)) self.logger.info(" waittime = " + str(docloud_context.waittime)) self.logger.info(" timeout = " + str(docloud_context.timeout)) self.jobInfo = None self.run_deterministic = docloud_context.run_deterministic self.log_output = log_output self.timed_out = False self.results = {}