2014-12-18 66 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