首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pyomo/CBC:限制迭代次数

Pyomo/CBC:限制迭代次数
EN

Stack Overflow用户
提问于 2022-08-23 20:49:04
回答 2查看 127关注 0票数 0

我正在用cbc解决一个Pyomo模型,使用:

代码语言:javascript
复制
solver  = SolverFactory('cbc')
results = solver.solve(model, tee=False)

是否有可能让cbc/pyomo在特定次数的迭代之后提前终止?

尝试按照max_iter中的建议设置this SO选项,但当使用cbc作为求解器时,它似乎不起作用。

EN

回答 2

Stack Overflow用户

发布于 2022-08-23 21:32:50

除了上面提到的另一个答案,我通常需要在不同的求解者之间找到正确的关键字.

如果您的cbc安装是“标准的”,并且您可以(并且应该能够)从命令行访问它,只需在命令行中键入"cbc“,然后用问号查看选项/命令,然后输入该命令以获取更多信息。

我通常不需要限制迭代,我认为这有点武断.如果模型是长的,我通常会给它加上一个时间限制和一个相对的间隙限制,我发现这个限制更有用,可以达到这样的效果:

代码语言:javascript
复制
solver.options = { 'sec': <sec>,  'threads':6, 'ratio': 0.02}

航站楼的例子:

代码语言:javascript
复制
~ % cbc
Welcome to the CBC MILP Solver 
Version: 2.10.8 
Build Date: Jul 21 2022 

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)
Branch and Cut keyword parameters:
 clique(Cuts) combine(Solutions) combine2(Solutions) constraint(fromCutoff)
 cost(Strategy) cplex(Use) cuts(OnOff) Dins DivingS(ome) DivingC(oefficient)
 DivingF(ractional) DivingG(uided) DivingL(ineSearch) DivingP(seudoCost)
 DivingV(ectorLength) dw(Heuristic) feas(ibilityPump) flow(CoverCuts) GMI(Cuts)
 gomory(Cuts) greedy(Heuristic) heur(isticsOnOff) knapsack(Cuts) lagomory(Cuts)
 latwomir(Cuts) lift(AndProjectCuts) local(TreeSearch)
 mixed(IntegerRoundingCuts) node(Strategy) PrepN(ames) pivotAndC(omplement)
 pivotAndF(ix) preprocess probing(Cuts) proximity(Search) randomi(zedRounding)
 reduce(AndSplitCuts) reduce2(AndSplitCuts) residual(CapacityCuts) Rens Rins
 round(ingHeuristic) sosO(ptions) sosP(rioritize) two(MirCuts)
 Vnd(VariableNeighborhoodSearch) zero(HalfCuts)
Actions or string parameters:
 allS(lack) barr(ier) basisI(n) basisO(ut) directory dualS(implex)
 either(Simplex) end exit export gsolu(tion) guess help import initialS(olve)
 max(imize) min(imize) para(metrics) primalS(implex) printM(ask) quit
 restoreS(olution) saveS(olution) solu(tion) stat(istics) stop
Branch and Cut actions:
 branch(AndCut) doH(euristic) mips(tart) nextB(estSolution) prio(rityIn) solv(e)
Coin:maxIT?
maxIt(erations) : Maximum number of iterations before stopping
Coin:
票数 2
EN

Stack Overflow用户

发布于 2022-08-23 21:22:08

选项名可能因求解器而异,因此请再次检查cbc的有效求解器选项,以找到指定最大迭代次数的选项,然后按所链接的so post中所述进行设置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73464910

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档