Skip to content

Commit

Permalink
avoid accessing auxs that were written off (i.e. their Multiplicity()…
Browse files Browse the repository at this point in the history
…==0) and whose Image() is NULL
  • Loading branch information
merraksh committed Oct 30, 2014
1 parent 7b1f01c commit 0cec0bf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Couenne/src/expression/CouenneExprAux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ class exprAux: public exprVar {

return ((integer_ == Integer) ||
((integer_ == Unset) &&
((integer_ = (image_ -> isInteger ()) ?
Integer : Continuous) == Integer)));
((integer_ = ((image_ != NULL) && (image_ -> isInteger ())) ?
Integer : Continuous) == Integer)));
}

/// is this expression integer?
Expand Down Expand Up @@ -209,7 +209,10 @@ class exprAux: public exprVar {

struct compExpr {
inline bool operator () (exprAux* e0, exprAux* e1) const
{return ((e0 -> sign () < e1 -> sign ()) || (e0 -> Image () -> compare (*(e1 -> Image ())) < 0));}
{
return ((e0 -> sign () < e1 -> sign ()) ||
((e0 -> Image () != NULL) && (e1 -> Image () != NULL) && (e0 -> Image () -> compare (*(e1 -> Image ())) < 0)));
}
};


Expand Down
1 change: 1 addition & 0 deletions Couenne/src/problem/fillDependence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void CouenneProblem::fillDependence (Bonmin::BabSetupBase *base, CouenneCutGener
i != variables_.end (); ++i) {

if (((*i) -> Type () == AUX) // consider auxs only
&& ((*i) -> Multiplicity () > 0)
&& ((*i) -> Image () -> Linearity () > LINEAR)) { // and nonlinear

CouenneObject *infeasObj = (*i) -> properObject (cg, this, base, jnlst_);
Expand Down
3 changes: 3 additions & 0 deletions Couenne/src/problem/problem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ void CouenneProblem::realign () {
for (std::vector <exprVar *>::iterator i = variables_.begin ();
i != variables_.end (); ++i) {

if ((*i) -> Multiplicity () <= 0)
continue;

(*i) -> linkDomain (&domain_);
(*i) -> realign (this);
if ((*i) -> Type () == AUX)
Expand Down
5 changes: 4 additions & 1 deletion Couenne/src/standardize/standardize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ bool CouenneProblem::standardize () {
for (std::vector <exprVar *>::iterator i = variables_.begin ();
i != variables_.end (); ++i)

if (((*i) -> Type () == AUX) && ((*i) -> sign () == expression::AUX_EQ)) {
if (((*i) -> Multiplicity () > 0) && ((*i) -> Type () == AUX) && ((*i) -> sign () == expression::AUX_EQ)) {

int type = (*i) -> Image () -> Type ();

Expand Down Expand Up @@ -520,6 +520,9 @@ bool CouenneProblem::standardize () {

int ord = numbering_ [i];

if (variables_ [ord] -> Multiplicity () <= 0)
continue;

if (variables_ [ord] -> Type () == AUX) {

// initial auxiliary bounds are infinite (they are later changed
Expand Down

0 comments on commit 0cec0bf

Please sign in to comment.