12 #include "CoinHelperFunctions.hpp"
22 using namespace Couenne;
46 x_ = CoinCopyOfArray (x, p -> nVars ());
48 for (std::vector <exprVar *>::iterator i = p ->
Variables (). begin ();
52 if ((*i) -> Multiplicity () <= 0)
60 double inf = CoinMax (vval - floor (vval +
COUENNE_EPS),
72 if (((*i) -> Type () ==
AUX) &&
73 ((*i) -> Image () -> Linearity () >
LINEAR)) {
77 fval = (*((*i) -> Image ())) ();
96 x_ (src.x_ ? CoinCopyOfArray (src.x_, src.n_) : NULL),
98 nNLinf_ (src.nNLinf_),
100 objVal_ (src.objVal_),
101 maxNLinf_ (src.maxNLinf_),
102 maxIinf_ (src.maxIinf_),
104 problem_ (src.problem_) {}
110 x_ = src.
x_ ? CoinCopyOfArray (src.
x_, src.
n_) : NULL;
133 switch (comparedTerm) {
149 if (((*i) -> Multiplicity () > 0) &&
152 int indVar = (*i) -> Index ();
159 printf (
" (%d,%g,%g,%g)", indVar,
x_ [indVar], other.
x_ [indVar],
x_ [indVar] - other.
x_ [indVar]);
162 printf (
"\n-----\n");
181 if ((*i) -> Multiplicity () > 0) {
183 int indVar = (*i) -> Index ();
193 printf (
"CouenneFPsolution::compare: bad compared term\n");
201 problem_ (src.problem_) {}
236 double bestdist = COIN_DBL_MAX;
237 std::set <CouenneFPsolution, compareSol>::iterator bestsol =
set_.
end ();
241 for (std::set <CouenneFPsolution, compareSol>::iterator i =
set_. begin ();
250 const register double
254 register bool move_on =
false;
256 for (
int j = nvars,
k=0;
j--; ++
k) {
262 if (
problem_ -> Var (
k) -> Multiplicity () <= 0)
265 dist += delta * delta;
267 if (dist >= bestdist) {
278 if( dist < bestdist )
286 bestsol =
set_. begin ();
291 sol = CoinCopyOfArray ((*bestsol).x(), nvars);
292 set_. erase(bestsol);
~CouenneFPsolution()
destructor
CouenneFPsolution(CouenneProblem *p, CouNumber *x, bool copied=false)
CouenneProblem-aware constructor.
static Bigint * diff(Bigint *a, Bigint *b)
CouNumber maxNLinf_
maximum NL infeasibility
bool operator()(const CouenneFPsolution &one, const CouenneFPsolution &two) const
compare, base version
bool compare(const CouenneFPsolution &other, enum what_to_compare comparedTerm) const
basic comparison procedure – what to compare depends on user's choice
int n_
number of variables (for independence from CouenneProblem)
int nNLinf_
number of NL infeasibilities
what_to_compare
what term to compare: the sum of infeasibilities, the sum of numbers of infeasible terms...
CouenneFPsolution & operator=(const CouenneFPsolution &src)
assignment
Class containing a solution with infeasibility evaluation.
void findClosestAndReplace(double *&sol, const double *nSol, int nvars)
finds, in pool, solution x closest to sol; removes it from the pool and overwrites it to sol ...
CouenneFPpool(CouenneProblem *p, enum what_to_compare c)
simple constructor (empty pool)
CouenneFPpool & operator=(const CouenneFPpool &src)
assignment
static enum Couenne::what_to_compare comparedTerm_
bool copied_
This is a temporary copy, not really a solution holder.
CouenneProblem * problem_
Problem pointer.
Class for MINLP problems with symbolic information.
const double * x() const
returns vector
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real * s
double CouNumber
main number type in Couenne
CouNumber objVal_
objective function value
int nIinf_
number of integer infeasibilities
The in-memory representation of the variables element.
std::set< CouenneFPsolution, compareSol > set_
Pool.
CouenneProblem * problem_
holds pointer to problem to check integrality in comparison of integer variables
static const double COMP_TOLERANCE
CouNumber maxIinf_
maximum integer infeasibility
void fint fint fint real fint real * x
bool isInteger(CouNumber x)
is this number integer?