2014-12-18 40 views
0

我正在使用PuLP线性编程模块来解决Python的线性问题。更改PuLP(用于Python)约束公差

我设置的问题,约束,我用提供纸浆的默认求解器是CBC(我的Mac求解器可执行文件名为CBC-OSX-64出于显而易见的原因)。当运行这个可执行文件时:

Welcome to the CBC MILP Solver 
Version: 2.7.6 
Build Date: Mar 3 2013 
Revision Number: 1770 

好吧,我通过PuLP运行求解器并获得解决方案。在验证约束满足时,我得到了解决方案和我所要求的(对于一些约束,并非全部)之间的差异,其小于1e-6但大于1e-7(例如1.6e-7) 。

当然,有一个约束容忍是有道理的,这很好。但我需要能够控制这一点,我认为这应该是任何LP任务中非常重要的参数。 (“?”运行可执行文件和类型)

因此,让我们看看来自CBC求解器的“帮助”,这些都是争论,我可以改变:

Commands are: 
Double parameters: 
    dualB(ound) dualT(olerance) primalT(olerance) primalW(eight) 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) 
    slog(Level) sprint(Crash) 
Branch and Cut integer parameters: 
    cutD(epth) cutL(ength) depth(MiniBab) hot(StartMaxIts) log(Level) maxN(odes) 
    maxS(olutions) passC(uts) passF(easibilityPump) passT(reeCuts) pumpT(une) 
    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) cost(Strategy) cplex(Use) 
    cuts(OnOff) Dins DivingS(ome) DivingC(oefficient) DivingF(ractional) 
    DivingG(uided) DivingL(ineSearch) DivingP(seudoCost) DivingV(ectorLength) 
    feas(ibilityPump) flow(CoverCuts) gomory(Cuts) greedy(Heuristic) 
    heur(isticsOnOff) knapsack(Cuts) lagomory(Cuts) lift(AndProjectCuts) 
    local(TreeSearch) mixed(IntegerRoundingCuts) node(Strategy) 
    pivotAndC(omplement) pivotAndF(ix) preprocess probing(Cuts) 
    rand(omizedRounding) reduce(AndSplitCuts) residual(CapacityCuts) Rens Rins 
    round(ingHeuristic) sos(Options) two(MirCuts) Vnd(VariableNeighborhoodSearch) 
Actions or string parameters: 
    allS(lack) barr(ier) basisI(n) basisO(ut) directory dualS(implex) 
    either(Simplex) end exit export gsolu(tion) help import initialS(olve) 
    max(imize) min(imize) para(metrics) primalS(implex) printM(ask) quit 
    saveS(olution) solu(tion) stat(istics) stop 
Branch and Cut actions: 
    branch(AndCut) doH(euristic) prio(rityIn) solv(e) 

这些参数的值具有值:

dualTolerance has value 1e-07 
primalTolerance has value 1e-07 
zeroTolerance has value 1e-20 
allowableGap has value 0 
integerTolerance has value 1e-06 
preTolerance has value 1e-08 
ratioGap has value 0 

唯一可以与约束容差相关联的参数,也与我的观察一致的是“整数容忍度”。因此,我将这个容差改为1e-8,但得到了相同的结果(即解决方案与地面真值相差超过1e-7)。

问题: 任何人都可以对此有所了解吗?特别是,有没有办法设置约束容差(找到的解决方案与我们所要求的不同之处)? 如果不是CBC,您是否知道可以设置此数量的其他解算器(GLPK,Gurobi等)?

谢谢。

回答

0

我不能给你一个确切的答案,但我会尝试原始或双重容忍。对我而言,整数容忍对于约束没有意义。

您是否知道如何通过Python界面更改这些选项(我想尝试一下,但不想调用命令行工具,而且我无法将选项传递给求解器) ?

+2

无关:我认为这个答案会更适合SO的指导方针作为评论。 – VHarisop