Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

dbtools.cc

Go to the documentation of this file.
00001 // Database tools implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2003 Hermann Schichl
00004 //
00005 // This file is part of the COCONUT API.  This library
00006 // is free software; you can redistribute it and/or modify it under the
00007 // terms of the Library GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // Library GNU General Public License for more details.
00015 
00016 // As a special exception, you may use this file as part of a free software
00017 // library without restriction.  Specifically, if other files instantiate
00018 // templates or use macros or inline functions from this file, or you compile
00019 // this file and link it with other files to produce an executable, this
00020 // file does not by itself cause the resulting executable to be covered by
00021 // the Library GNU General Public License.  This exception does not however
00022 // invalidate any other reasons why the executable file might be covered by
00023 // the Library GNU General Public License.
00024 
00027 #include <search_node.h>
00028 #include <dbtools.h>
00029 #include <int_evaluator.h>
00030 
00031 bool point_check_feasibility::operator() () const
00032 {
00033   typedef model::walker nodeptr;
00034   const std::vector<double>* x;
00035   const double* f;
00036 
00037   bool error;
00038   const vdbl::col& _ca(_r->get_col(x_ci, error));
00039   if(error) return false;
00040   _ca.get_ptr(x);
00041 
00042   const vdbl::col& _cb(_r->get_col(f_ci, error));
00043   if(error) return false;
00044   _cb.get_ptr(f);
00045 
00046   const work_node *wn = wnc->wn()->get_local_copy();
00047   const model* __mod = wn->get_model_ptr();
00048   variable_indicator v_i(__mod->number_of_variables());
00049   v_i.set(0, __mod->number_of_variables());
00050 
00051   std::vector<interval> xi;
00052   std::copy((*x).begin(), (*x).end(), std::back_inserter(xi));
00053   interval fi;
00054   interval_eval ie(xi, v_i, *__mod, NULL, false);
00055 
00056   std::vector<nodeptr>::const_iterator __b, __e(__mod->constraints.end());
00057   for(__b = __mod->constraints.begin(); __b != __e; ++__b)
00058   {
00059     fi = evaluate(ie, *__b);
00060     if(!fi.subset((*__b)->f_bounds))
00061       return false;
00062   }
00063   return true;
00064 }
00065 
00066 bool box_check_intersection::operator() () const
00067 {
00068   typedef model::walker nodeptr;
00069   const std::vector<interval>* x;
00070 
00071   bool error;
00072   const vdbl::col& _ca(_r->get_col(x_ci, error));
00073   if(error) return false;
00074   _ca.get_ptr(x);
00075 
00076   const work_node *wn = wnc->wn()->get_local_copy();
00077   const model* __mod = wn->get_model_ptr();
00078   const std::vector<interval>& ranges(wn->node_ranges);
00079 
00080   unsigned int e(x->size());
00081   for(unsigned int i = 0; i < e; ++i)
00082   {
00083     if((*x)[i].disjoint(ranges[__mod->var(i)->node_num]))
00084       return false;
00085   }
00086   return true;
00087 }

Generated on Tue Nov 4 01:57:57 2003 for COCONUT API by doxygen1.2.18