public void SonnetCbcTest2() { Console.WriteLine("SonnetCbcTest2 - Cbc set CbcStrategyDefault"); Model model = Model.New("MIP-124725.mps"); // added file to project, "Copy Always" Solver solver = new Solver(model, typeof(OsiCbcSolverInterface)); model.ObjectiveSense = ObjectiveSense.Minimise; OsiCbcSolverInterface osisolver = solver.OsiSolver as OsiCbcSolverInterface; Assert.IsTrue(osisolver != null); CbcModel cbcModel = osisolver.getModelPtr(); cbcModel.setStrategy(new CbcStrategyDefault(1, 5, 5)); //cbcModel.strategy().setupCutGenerators(cbcModel); solver.AutoResetMIPSolve = true; solver.Minimise(); string message = "Used cut generators: " + string.Join(", ", cbcModel.cutGenerators().Select(generator => generator.generator().GetType().Name)); Console.WriteLine(message); Assert.IsTrue(Utils.EqualsDouble(model.Objective.Value, 124725)); solver.Solve(true); Assert.IsTrue(Utils.EqualsDouble(model.Objective.Value, 104713.12807881772)); }
public void SonnetCbcTest1() { Console.WriteLine("SonnetCbcTest1 - Cbc test set CbcStrategyNull and addCutGenerator"); Model model = Model.New("MIP-124725.mps"); // added file to project, "Copy Always"; Solver solver = new Solver(model, typeof(OsiCbcSolverInterface)); OsiCbcSolverInterface osisolver = solver.OsiSolver as OsiCbcSolverInterface; Assert.IsTrue(osisolver != null); CbcModel cbcModel = osisolver.getModelPtr(); cbcModel.setStrategy(new CbcStrategyNull()); cbcModel.addCutGenerator(new CglProbing()); Assert.IsTrue(cbcModel.numberCutGenerators() == 1); //cbcModel.cutGenerators(); solver.Minimise(); Assert.IsTrue(Utils.EqualsDouble(model.Objective.Value, 124725)); //Assert.IsTrue(Utils.EqualsDouble(model.Objective.Value, 104713.12807881772)); }