diff --git a/doc/source/modeling-tools.rst b/doc/source/modeling-tools.rst index 0657ae9ed..a1204b733 100644 --- a/doc/source/modeling-tools.rst +++ b/doc/source/modeling-tools.rst @@ -330,7 +330,7 @@ Running Gurobi with option ``feasrelax 1``, we trick MP After the solver log we see a warning of type "Tolerance violations". There is an absolute violation of 3 and relative violation of 1 in the objective value. Linear constraint `C2` has its absolute and relative violations reported. -Lines markes with a `*` report :ref:`Realistic violations `. +Lines marked with a `*` report :ref:`Realistic violations `. To check the violations, we can recompute objective value and constraint slacks, as follows: @@ -426,7 +426,8 @@ Consider the following example. .. code-block:: ampl var x >=0, <=100; - maximize Total: if x<=5 and x>=5.00000000001 then 10; + maximize Total: + if x<=5 and x>=5.00000000001 then 10; Most solvers apply a constraint feasibility tolerance of the order :math:`10^{-6}`. diff --git a/solvers/cbcmp/cbcmpmodelapi.cc b/solvers/cbcmp/cbcmpmodelapi.cc index 7ac19bab5..2be80b87b 100644 --- a/solvers/cbcmp/cbcmpmodelapi.cc +++ b/solvers/cbcmp/cbcmpmodelapi.cc @@ -27,6 +27,8 @@ void CbcmpModelAPI::AddVariables(const VarArrayDef& v) { void CbcmpModelAPI::SetLinearObjective( int iobj, const LinearObjective& lo ) { if (iobj<1) { + for (auto i=NumVars(); i--; ) + Cbc_setObjCoeff(lp(), i, 0.0); for (int i = 0; i < lo.num_terms(); i++) Cbc_setObjCoeff(lp(), lo.vars()[i], lo.coefs()[i]); Cbc_setObjSense(lp(), lo.obj_sense()== obj::MAX ? -1 : 1);