def __new__(cls, *args, **kwds): mode = kwds.pop('solver_io', 'lp') if mode is None: mode = 'lp' # if mode == 'lp': return SolverFactory('_gurobi_shell', **kwds) if mode == 'mps': opt = SolverFactory('_gurobi_shell', **kwds) opt.set_problem_format(ProblemFormat.mps) return opt if mode in ['python', 'direct']: opt = SolverFactory('gurobi_direct', **kwds) if opt is None: logger.error('Python API for GUROBI is not installed') return return opt if mode == 'persistent': opt = SolverFactory('gurobi_persistent', **kwds) if opt is None: logger.error('Python API for GUROBI is not installed') return return opt # if mode == 'os': opt = SolverFactory('_ossolver', **kwds) elif mode == 'nl': opt = SolverFactory('asl', **kwds) else: logger.error('Unknown IO type: %s' % mode) return opt.set_options('solver=gurobi_ampl') return opt
def __new__(cls, *args, **kwds): try: mode = kwds['solver_io'] if mode is None: mode = 'lp' del kwds['solver_io'] except KeyError: mode = 'lp' if mode == 'lp': return SolverFactory('_xpress_shell', **kwds) elif mode == 'mps': opt = SolverFactory('_xpress_shell', **kwds) opt.set_problem_format(ProblemFormat.mps) return opt elif mode == 'nl': opt = SolverFactory('asl', **kwds) elif mode in ['python', 'direct']: opt = SolverFactory('xpress_direct', **kwds) if opt is None: logger.error('Python API for XPRESS is not installed') return return opt elif mode == 'persistent': opt = SolverFactory('xpress_persistent', **kwds) if opt is None: logger.error('Python API for XPRESS is not installed') return return opt else: logging.getLogger('pyomo.solvers').error( 'Unknown IO type for solver xpress: %s' % (mode)) return opt.set_options('solver=amplxpress') return opt
def __new__(cls, *args, **kwds): mode = kwds.pop('solver_io', 'lp') if mode == 'lp' or mode is None: opt = SolverFactory('_cbc_shell', **kwds) opt.set_problem_format(ProblemFormat.cpxlp) return opt # CBC's MPS parser seems too buggy to expose # this option # if mode == 'mps': # # *NOTE: CBC uses the COIN-OR MPS reader, # # which ignores any objective sense # # declared in the OBJSENSE section. # opt = SolverFactory('_cbc_shell', **kwds) # opt.set_problem_format(ProblemFormat.mps) # return opt # if mode == 'nl': # CBC doesn't not accept all asl style command line # options (-s in particular, which is required for # streaming output of all asl solvers). Therefore we need # to send it through the cbc_shell instead of ASL opt = SolverFactory('_cbc_shell', **kwds) opt.set_problem_format(ProblemFormat.nl) return opt elif mode == 'os': opt = SolverFactory('_ossolver', **kwds) opt.set_options('solver=cbc') return opt else: logger.error('Unknown IO type: %s' % mode) return
def __new__(cls, *args, **kwds): try: mode = kwds['solver_io'] if mode is None: mode = 'lp' del kwds['solver_io'] except KeyError: mode = 'lp' # if mode == 'lp': opt = SolverFactory('_pico_shell', **kwds) opt.set_problem_format(ProblemFormat.cpxlp) return opt # PICO's MPS parser seems too buggy to expose # this option # if mode == 'mps': # opt = SolverFactory('_pico_shell', **kwds) # opt.set_problem_format(ProblemFormat.mps) # return opt # if mode == 'nl': # PICO does not accept all asl style command line options # (-s in particular, which is required for streaming output of # all asl solvers). Therefore we need to send it through the cbc_shell # instead of ASL opt = SolverFactory('_pico_shell',**kwds) opt.set_problem_format(ProblemFormat.nl) elif mode == 'os': opt = SolverFactory('_ossolver', **kwds) else: logger.error('Unknown IO type: %s' % mode) return opt.set_options('solver=PICO') return opt
def __new__(cls, *args, **kwds): configure_cbc() try: mode = kwds['solver_io'] if mode is None: mode = 'lp' del kwds['solver_io'] except KeyError: mode = 'lp' # if mode == 'lp': opt = SolverFactory('_cbc_shell', **kwds) opt.set_problem_format(ProblemFormat.cpxlp) return opt # CBC's MPS parser seems too buggy to expose # this option # if mode == 'mps': # # *NOTE: CBC uses the COIN-OR MPS reader, # # which ignores any objective sense # # declared in the OBJSENSE section. # opt = SolverFactory('_cbc_shell', **kwds) # opt.set_problem_format(ProblemFormat.mps) # return opt # if mode == 'nl': # the _cbc_compiled_with_asl and # _cbc_old_version flags are tristate # (None, False, True), so don't # simplify the if statements from # checking "is" if _cbc_compiled_with_asl is not False: if _cbc_old_version is True: logger.warning("found CBC version " + _version_to_string(_cbc_version) + " < 2.7; ASL support disabled.") logger.warning("Upgrade CBC to activate ASL " "support in this plugin") else: logger.warning("CBC solver is not compiled with ASL " "interface.") # CBC doesn't not accept all asl style command line # options (-s in particular, which is required for # streaming output of all asl solvers). Therefore we need # to send it through the cbc_shell instead of ASL opt = SolverFactory('_cbc_shell', **kwds) opt.set_problem_format(ProblemFormat.nl) return opt elif mode == 'os': opt = SolverFactory('_ossolver', **kwds) else: logger.error('Unknown IO type: %s' % mode) return opt.set_options('solver=cbc') return opt
def __new__(cls, *args, **kwds): try: mode = kwds['solver_io'] if mode is None: mode = 'lp' del kwds['solver_io'] except KeyError: mode = 'lp' # if mode == 'lp': return SolverFactory('_cplex_shell', **kwds) if mode == 'mps': opt = SolverFactory('_cplex_shell', **kwds) opt.set_problem_format(ProblemFormat.mps) return opt if mode in ['python', 'direct']: opt = SolverFactory('cplex_direct', **kwds) if opt is None: logging.getLogger('pyomo.solvers').error( 'Python API for CPLEX is not installed') return return opt if mode == 'persistent': opt = SolverFactory('cplex_persistent', **kwds) if opt is None: logging.getLogger('pyomo.solvers').error( 'Python API for CPLEX is not installed') return return opt # if mode == 'os': opt = SolverFactory('_ossolver', **kwds) elif mode == 'nl': opt = SolverFactory('asl', **kwds) else: logging.getLogger('pyomo.solvers').error('Unknown IO type: %s' % mode) return opt.set_options('solver=cplexamp') return opt