Skip to content

Commit

Permalink
Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
chschulte committed Feb 7, 2019
1 parent 37288ae commit 7d8fbfd
Show file tree
Hide file tree
Showing 14 changed files with 7,366 additions and 7,058 deletions.
13,954 changes: 7,069 additions & 6,885 deletions Makefile.dep

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,9 @@ MMSRC0 = \
float-expr.cpp float-rel.cpp float-arith.cpp \
reg.cpp optimize.cpp exception.cpp ipl.cpp
MMHDR0 = \
int-rel.hpp float-rel.hpp exception.hpp matrix.hpp \
int-expr.hpp int-rel.hpp float-expr.hpp float-rel.hpp \
bool-expr.hpp set-expr.hpp set-rel.hpp \
exception.hpp matrix.hpp \
optimize.hpp reg.hpp ldsb.hpp channel.hpp aliases.hpp \
ipl.hpp

Expand Down
61 changes: 29 additions & 32 deletions gecode/minimodel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -224,25 +224,23 @@ namespace Gecode {
virtual void post(Home home, IntRelType irt, int c,
BoolVar b, const IntPropLevels& ipls) const = 0;
/// Destructor
virtual ~NonLinIntExpr(void) {}
/// Return fresh variable if \a x is NULL, \a x otherwise
static IntVar result(Home home, IntVar* x) {
if (x==NULL)
return IntVar(home,Int::Limits::min,Int::Limits::max);
return *x;
}
/// Constrain \a x to be equal to \a y if \a x is not NULL
static IntVar result(Home home, IntVar* x, IntVar y) {
if (x!=NULL)
rel(home,*x,IRT_EQ,y);
return y;
}
virtual ~NonLinIntExpr(void);
/// Return fresh variable if \a x is null, \a x otherwise
static IntVar result(Home home, IntVar* x);
/// Constrain \a x to be equal to \a y if \a x is not null
static IntVar result(Home home, IntVar* x, IntVar y);
/// Memory management
void* operator new(size_t size) { return heap.ralloc(size); }
void* operator new(size_t s);
/// Memory management
void operator delete(void* p, size_t) { heap.rfree(p); }
void operator delete(void* p, size_t s);
};

}

#include <gecode/minimodel/int-expr.hpp>

namespace Gecode {

/// Linear expressions over integer variables
class LinIntExpr {
friend class LinIntRel;
Expand Down Expand Up @@ -323,7 +321,7 @@ namespace Gecode {
/// Post propagator and return variable for value
GECODE_MINIMODEL_EXPORT
IntVar post(Home home, const IntPropLevels& ipls) const;
/// Return non-linear expression inside, or NULL if not non-linear
/// Return non-linear expression inside, or null if not non-linear
GECODE_MINIMODEL_EXPORT
NonLinIntExpr* nle(void) const;
/// Destructor
Expand Down Expand Up @@ -791,6 +789,7 @@ namespace Gecode {
//@}

#ifdef GECODE_HAS_FLOAT_VARS

/// Base class for non-linear float expressions
class NonLinFloatExpr {
public:
Expand All @@ -802,25 +801,23 @@ namespace Gecode {
virtual void post(Home home, FloatRelType frt, FloatVal c,
BoolVar b) const = 0;
/// Destructor
virtual ~NonLinFloatExpr(void) {}
/// Return fresh variable if \a x is NULL, \a x otherwise
static FloatVar result(Home home, FloatVar* x) {
if (x == NULL)
return FloatVar(home,Float::Limits::min,Float::Limits::max);
return *x;
}
/// Constrain \a x to be equal to \a y if \a x is not NULL
static FloatVar result(Home home, FloatVar* x, FloatVar y) {
if (x!=NULL)
rel(home,*x,FRT_EQ,y);
return y;
}
virtual ~NonLinFloatExpr(void);
/// Return fresh variable if \a x is null, \a x otherwise
static FloatVar result(Home home, FloatVar* x);
/// Constrain \a x to be equal to \a y if \a x is not null
static FloatVar result(Home home, FloatVar* x, FloatVar y);
/// Memory management
void* operator new(size_t size) { return heap.ralloc(size); }
void* operator new(size_t s);
/// Memory management
void operator delete(void* p, size_t) { heap.rfree(p); }
void operator delete(void* p, size_t s);
};

}

#include <gecode/minimodel/float-expr.hpp>

namespace Gecode {

/// %Float expressions
class LinFloatExpr {
friend class LinFloatRel;
Expand Down Expand Up @@ -885,7 +882,7 @@ namespace Gecode {
/// Post propagator and return variable for value
GECODE_MINIMODEL_EXPORT
FloatVar post(Home home) const;
/// Return non-linear expression inside, or NULL if not non-linear
/// Return non-linear expression inside, or null if not non-linear
GECODE_MINIMODEL_EXPORT
NonLinFloatExpr* nlfe(void) const;
/// Destructor
Expand Down
34 changes: 17 additions & 17 deletions gecode/minimodel/bool-expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace Gecode {
*
*/
BoolExpr::Node::Node(void)
: use(1), l(NULL), r(NULL), m(NULL) {}
: use(1), l(nullptr), r(nullptr), m(nullptr) {}

BoolExpr::Node::~Node(void) {
delete m;
Expand All @@ -102,9 +102,9 @@ namespace Gecode {
bool
BoolExpr::Node::decrement(void) {
if (--use == 0) {
if ((l != NULL) && l->decrement())
if ((l != nullptr) && l->decrement())
delete l;
if ((r != NULL) && r->decrement())
if ((r != nullptr) && r->decrement())
delete r;
return true;
}
Expand All @@ -120,8 +120,8 @@ namespace Gecode {
BoolExpr::BoolExpr(const BoolVar& x) : n(new Node) {
n->same = 1;
n->t = NT_VAR;
n->l = NULL;
n->r = NULL;
n->l = nullptr;
n->r = nullptr;
n->x = x;
}

Expand Down Expand Up @@ -149,16 +149,16 @@ namespace Gecode {
n->t = NT_NOT;
n->l = l.n;
n->l->use++;
n->r = NULL;
n->r = nullptr;
}
}

BoolExpr::BoolExpr(const LinIntRel& rl)
: n(new Node) {
n->same = 1;
n->t = NT_RLIN;
n->l = NULL;
n->r = NULL;
n->l = nullptr;
n->r = nullptr;
n->rl = rl;
}

Expand All @@ -167,8 +167,8 @@ namespace Gecode {
: n(new Node) {
n->same = 1;
n->t = NT_RLINFLOAT;
n->l = NULL;
n->r = NULL;
n->l = nullptr;
n->r = nullptr;
n->rfl = rfl;
}
#endif
Expand All @@ -178,17 +178,17 @@ namespace Gecode {
: n(new Node) {
n->same = 1;
n->t = NT_RSET;
n->l = NULL;
n->r = NULL;
n->l = nullptr;
n->r = nullptr;
n->rs = rs;
}

BoolExpr::BoolExpr(const SetCmpRel& rs)
: n(new Node) {
n->same = 1;
n->t = NT_RSET;
n->l = NULL;
n->r = NULL;
n->l = nullptr;
n->r = nullptr;
n->rs = rs;
}
#endif
Expand All @@ -197,8 +197,8 @@ namespace Gecode {
: n(new Node) {
n->same = 1;
n->t = NT_MISC;
n->l = NULL;
n->r = NULL;
n->l = nullptr;
n->r = nullptr;
n->m = m;
}

Expand Down Expand Up @@ -566,7 +566,7 @@ namespace Gecode {
GECODE_NEVER;
}
GECODE_NEVER;
return NULL;
return nullptr;
}
}

Expand Down
6 changes: 3 additions & 3 deletions gecode/minimodel/float-arith.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,18 +304,18 @@ namespace Gecode { namespace MiniModel {
x[i] = a[i].post(home);
rel(home, x, frt, c);
} else {
rel(home, post(home,NULL), frt, c);
rel(home, post(home,nullptr), frt, c);
}
}
virtual void post(Home home, FloatRelType frt, FloatVal c,
BoolVar b) const {
rel(home, post(home,NULL), frt, c, b);
rel(home, post(home,nullptr), frt, c, b);
}
};
/// Check if \a e is of type \a t
bool hasType(const LinFloatExpr& e, ArithNonLinFloatExpr::ArithNonLinFloatExprType t) {
return e.nlfe() &&
dynamic_cast<ArithNonLinFloatExpr*>(e.nlfe()) != NULL &&
dynamic_cast<ArithNonLinFloatExpr*>(e.nlfe()) != nullptr &&
dynamic_cast<ArithNonLinFloatExpr*>(e.nlfe())->t == t;
}

Expand Down
Loading

0 comments on commit 7d8fbfd

Please sign in to comment.