【问题标题】:How to define tolerance level in CBC solver using pyomo's solverfactory?如何使用pyomo的solverfactory在CBC求解器中定义容差水平?
【发布时间】:2022-01-05 20:58:31
【问题描述】:

我正在尝试使用 pyomo 的求解器工厂通过 CBC 求解 MIP,但是遇到了一些不可行的问题。在深入研究可能导致不可行的数据点之前,我想先尝试配置容差水平,看看是否可行。

但是当我使用这个命令时,cbc 求解器会输出一个错误:

options = {
            'tol': 0.0001
        }
        solver = SolverFactory(solver_type)
        solver.options.update(options)

谁能帮助我了解如何在 cbc 中定义容忍度?谢谢!

【问题讨论】:

    标签: pyomo coin-or-cbc


    【解决方案1】:

    所以,这取决于一点。假设您正在寻找混合整数程序的容差,CBC 的关键字是“比率”。

    这是一个运行 6 个线程,最长 20 秒,比率为 0.02(2% 间隙)的设置

    ### SOLVE
    solver = pyo.SolverFactory('cbc')
    solver.options = {'sec': 20, 'threads': 6, 'ratio': 0.02}
    results = solver.solve(mdl)
    print(results)
    

    这里有几种不同类型的语法可以接受...您可以将选项传递给 SolverFactory 等...但这对我来说很好。

    作为另一个技巧,我总是会挂断这些求解器的正确关键字......如果你正确安装了 CBC,你可以去终端,用命令打开 CBC cbc,应该会给你“硬币”提示并输入“?”查看命令。然后你可以使用命令和双'??'获取详细信息。这也适用于glpk,非常有帮助。

    例如:

    % cbc
    Welcome to the CBC MILP Solver 
    Version: 2.10.5 
    Build Date: Dec  5 2021 
    
    CoinSolver takes input from arguments ( - switches to stdin)
    Enter ? for list of commands or help
    Coin:?
    In argument list keywords have leading - , -stdin or just - switches to stdin
    One command per line (and no -)
    abcd? gives list of possibilities, if only one + explanation
    abcd?? adds explanation, if only one fuller help
    abcd without value (where expected) gives current value
    abcd value sets value
    Commands are:
    Double parameters:
     dualB(ound) dualT(olerance) primalT(olerance) primalW(eight) psi
     zeroT(olerance)
    Branch and Cut double parameters:
     allow(ableGap) cuto(ff) inc(rement) integerT(olerance) preT(olerance)
     pumpC(utoff) ratio(Gap) sec(onds)
    Integer parameters:
     force(Solution) idiot(Crash) maxF(actor) maxIt(erations) output(Format)
     randomS(eed) slog(Level) sprint(Crash)
    Branch and Cut integer parameters:
     cutD(epth) cutL(ength) depth(MiniBab) hot(StartMaxIts) log(Level) maxN(odes)
     maxSaved(Solutions) maxSo(lutions) passC(uts) passF(easibilityPump)
     passT(reeCuts) pumpT(une) randomC(bcSeed) slow(cutpasses) strat(egy)
     strong(Branching) trust(PseudoCosts)
    Keyword parameters:
     allC(ommands) chol(esky) crash cross(over) direction error(sAllowed)
     fact(orization) keepN(ames) mess(ages) perturb(ation) presolve
     printi(ngOptions) scal(ing) timeM(ode)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-09
      • 2017-02-17
      • 2020-08-27
      • 2022-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-07
      相关资源
      最近更新 更多