Open johnzigla opened 3 years ago
Here's a better example without JuMP:
using Cbc
ptr = Cbc_newModel()
Cbc_setParameter(ptr, "solve", "dualSimplex")
Cbc_loadProblem(
ptr,
1,
0,
C_NULL,
C_NULL,
C_NULL,
[0.0],
[1.0],
[1.0],
C_NULL,
C_NULL,
)
Cbc_setInteger(ptr, 0)
julia> Cbc_solve(ptr)
Welcome to the CBC MILP Solver
Version: 2.10.5
Build Date: Apr 14 2021
command line - Cbc_C_Interface -solve dualSimplex -solve -quit (default strategy 1)
Continuous objective value is 0 - 0.00 seconds
Cgl0004I processed model has 0 rows, 0 columns (0 integer (0 of which binary)) and 0 elements
Cbc3007W No integer variables - nothing to do
Cuts at root node changed objective from 0 to -1.79769e+308
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: 0.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 0.00
Time (Wallclock seconds): 0.00
Optimal - objective value 0
Optimal objective 0 - 0 iterations time 0.002
signal (11): Segmentation fault: 11
in expression starting at REPL[6]:1
unknown function (ip: 0x0)
Allocations: 5245964 (Pool: 5243004; Big: 2960); GC: 6
I guess you just shouldn't set solve
to dualSimplex
if it is a MIP? This issue trying to first solve with dualSimplex, then re-solve.
Calling the executable works:
shell> cat test.lp
\Problem name: ClpDefaultName
Minimize
obj: x0
Subject To
Bounds
0.300000000 <= x0 <= 1
Integers
x0
End
julia> Cbc_jll.cbc() do exe
run(`$(exe) test.lp -solve dualSimplex -solve -quit`)
end
Welcome to the CBC MILP Solver
Version: 2.10.5
Build Date: Apr 14 2021
command line - /Users/oscar/.julia/artifacts/fcc0f90ee62113a97e8e82c1b20a46265667d88d/bin/cbc test.lp -solve dualSimplex -solve -quit (default strategy 1)
Continuous objective value is 0.3 - 0.00 seconds
Cgl0004I processed model has 0 rows, 0 columns (0 integer (0 of which binary)) and 0 elements
Cbc3007W No integer variables - nothing to do
Cuts at root node changed objective from 1 to -1.79769e+308
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: 1.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 0.01
Time (Wallclock seconds): 0.00
Optimal - objective value 1
Optimal objective 1 - 0 iterations time 0.002
Continuous objective value is 1 - 0.00 seconds
Cgl0004I processed model has 0 rows, 0 columns (0 integer (0 of which binary)) and 0 elements
Cbc3007W No integer variables - nothing to do
Cbc3007W No integer variables - nothing to do
Cbc0006I The LP relaxation is infeasible or too expensive
Cbc0045I Solution of 1 already found by heuristic
Cuts at root node changed objective from 1.79769e+308 to -1.79769e+308
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: 1.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 0.00
Time (Wallclock seconds): 0.00
Total time (CPU seconds): 0.01 (Wallclock seconds): 0.00
Process(`/Users/oscar/.julia/artifacts/fcc0f90ee62113a97e8e82c1b20a46265667d88d/bin/cbc test.lp -solve dualSimplex -solve -quit`, ProcessExited(0))
I guess you just shouldn't set
solve
todualSimplex
if it is a MIP?
It is not dualSimplex
that gives segmentation fault, but specifying any method including barrier
. The only way around it is to not pass the parameter solve
and let CBC/CLP select the default method
Why are you trying to set the method for a MIP? Cbc will use branch and cut. It doesn't use pure dual simplex or barrier. As part of the branching, it will use dual simplex to solve the LPs, because the dual basis can be efficiently reused between nodes.
Thank you for looking into it.
Why are you trying to set the method for a MIP?
I don't understand what does solve
parameter do- I was under the impression that it sets method for the initial LP relaxation. I don't want to set a method for a MIP, if this is what this parameter will do.
solve
is an action, not a parameter. I'm not sure if there is a way to set the method for the root node.
There are two intertwined issues: Cbc_setParameter
should probably validate the set of arguments, rather than accepting them blindly; and mixing dualSimplex
and solve
should error, rather than segfault.
You can explore the options for Cbc as follows:
julia> Cbc_jll.cbc() do exe
run(`$exe`)
end
Welcome to the CBC MILP Solver
Version: 2.10.5
Build Date: Apr 14 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)
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:solve??
solv(e) : Solve problem
If there are no integer variables then this just solves LP. If there
are integer variables this does branch and cut.
Coin:dualSimplex??
dualS(implex) : Do dual simplex algorithm
This command solves the continuous relaxation of the current model
using the dual steepest edge algorithm.The time and iterations may
be affected by settings such as presolve, scaling, crash and also
by dual pivot method, fake bound on variables and dual and primal
tolerances.
The useful options are here: https://github.com/jump-dev/Cbc.jl#options
I agree that is should error. For a pure LP, method can be set using solve
and it works fine.
In addition to the options listed in the Julia wrapper, I find changing defaults for preprocess
to be helpful.
I agree that is a bug. Will try and fix (at least in master).
John ForrestOn 31/05/2021 23:03, Oscar Dowson wrote:
|solve| is an action, not a parameter. I'm not sure if there is a way to set the method for the root node.
There are two intertwined issues: |Cbc_setParameter| should probably validate the set of arguments, rather than accepting them blindly; and mixing |dualSimplex| and |solve| should error, rather than segfault.
You can explore the options for Cbc as follows:
julia > Cbc_jll.cbc()do exe run(
$exe
) end Welcome to the CBC MILP Solver Version: 2.10.5
Build Date: Apr14 2021CoinSolver takes input from arguments (- switches tostdin) Enter? for list of commands or help Coin:? In argument list keywords have leading- ,-stdin or just- switches tostdin 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) crashcross(over) directionerror(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) DinsDivingS(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) preprocessprobing(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) directorydualS(implex) either(Simplex)end exitexport gsolu(tion) guess helpimport 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:solve?? solv(e): Solve problem If there are no integer variables then this just solves LP. If there are integer variables this does branch and cut. Coin:dualSimplex?? dualS(implex): Do dual simplex algorithm This command solves the continuous relaxation of the current model using the dual steepest edge algorithm.The time and iterations may be affected by settings such as presolve, scaling, crash and also by dual pivot method, fake bound on variables and dual and primal tolerances.
The useful options are here: https://github.com/jump-dev/Cbc.jl#options https://github.com/jump-dev/Cbc.jl#options
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/coin-or/Cbc/issues/411#issuecomment-851698855, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWJYHFBZUNTXXQUW5QVTL3TQQBSHANCNFSM453ITH7Q.
Apologies for previous reply.
I can't get Cbc Cbc to fail, so I presume it is a failing in Julia - and I can't help there.
John Forrest On 31/05/2021 23:03, Oscar Dowson wrote:
|solve| is an action, not a parameter. I'm not sure if there is a way to set the method for the root node.
There are two intertwined issues: |Cbc_setParameter| should probably validate the set of arguments, rather than accepting them blindly; and mixing |dualSimplex| and |solve| should error, rather than segfault.
You can explore the options for Cbc as follows:
julia > Cbc_jll.cbc()do exe run(
$exe
) end Welcome to the CBC MILP Solver Version: 2.10.5
Build Date: Apr14 2021CoinSolver takes input from arguments (- switches tostdin) Enter? for list of commands or help Coin:? In argument list keywords have leading- ,-stdin or just- switches tostdin 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) crashcross(over) directionerror(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) DinsDivingS(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) preprocessprobing(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) directorydualS(implex) either(Simplex)end exitexport gsolu(tion) guess helpimport 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:solve?? solv(e): Solve problem If there are no integer variables then this just solves LP. If there are integer variables this does branch and cut. Coin:dualSimplex?? dualS(implex): Do dual simplex algorithm This command solves the continuous relaxation of the current model using the dual steepest edge algorithm.The time and iterations may be affected by settings such as presolve, scaling, crash and also by dual pivot method, fake bound on variables and dual and primal tolerances.
The useful options are here: https://github.com/jump-dev/Cbc.jl#options https://github.com/jump-dev/Cbc.jl#options
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/coin-or/Cbc/issues/411#issuecomment-851698855, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWJYHFBZUNTXXQUW5QVTL3TQQBSHANCNFSM453ITH7Q.
It's not a Julia issue. I can reproduce via the C API:
#include "Cbc_C_Interface.h"
int main (int argc, const char *argv[]) {
Cbc_Model* ptr;
ptr = Cbc_newModel();
Cbc_setParameter(ptr, "solve", "dualSimplex");
double zero[1] = {0.0};
double one[1] = {1.0};
Cbc_loadProblem(ptr, 1, 0, NULL, NULL, NULL, zero, one, one, NULL, NULL);
Cbc_setInteger(ptr, 0);
Cbc_solve(ptr);
Cbc_deleteModel(ptr);
return 0;
}
(base) oscar@Oscars-MBP coin-or % gcc -I/usr/local/include/coinutils/coin -I/usr/local/include/cbc/coin -lCbcSolver cbc_bug.c
(base) oscar@Oscars-MBP coin-or % ./a.out
Welcome to the CBC MILP Solver
Version: 2.10.5
Build Date: Aug 12 2020
command line - Cbc_C_Interface -solve dualSimplex -solve -quit (default strategy 1)
Continuous objective value is 0 - 0.00 seconds
Cgl0004I processed model has 0 rows, 0 columns (0 integer (0 of which binary)) and 0 elements
Cbc3007W No integer variables - nothing to do
Cuts at root node changed objective from 0 to -1.79769e+308
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: 0.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 0.00
Time (Wallclock seconds): 0.00
Optimal - objective value 0
Optimal objective 0 - 0 iterations time 0.002
zsh: segmentation fault ./a.out
This should be much better in Cbc 3.0. The parameter mechanism is being completely revamped and I'm trying to put in a lot more checks to make sure things make sense. I'll definitely run this example through the refactor branch to make sure it gives an error. I guess what it will do now is to warn that dualSimplex
is not a legal where it's at on the command line and just do one solve followed by another (useless) solve. @jjhforrest did recently fix a bug related to this kind of double solve, in case anyone tries it for some reason.
I am running into a segmentation fault with CBC solver, if I specify a method (such as dual simplex, barrier) to use for a MILP or for a pure binary linear program. This is done by setting the parameter
solve
asdualSimplex
. The solver finds a solution but then crashes. If I run it without specifying the method then it works fine.I am using JuMP/Julia to use Cbc solver and version of CBC is 2.10.5. The code below reproduces the error. This issue is also posted on discourse: https://discourse.julialang.org/t/bug-in-jump/62129
Is this an issue with CBC or am I doing something incorrectly?
Error message after CBC reports optimal solution