00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00028 #ifndef _DIAMETER_HOOK_H
00029 #define _DIAMETER_HOOK_H
00030
00031 #include <comp_hook.h>
00032
00033 namespace coco {
00034
00036
00042 class diameter_comp_hook : public wnc_hook_base
00043 {
00044 public:
00046 diameter_comp_hook() : wnc_hook_base("diameter") {}
00047
00049 virtual ~diameter_comp_hook() {}
00050
00052 diameter_comp_hook* new_copy() const { return new diameter_comp_hook(*this); }
00053
00056 void operator()(const work_node& wn, dbt_row& dbr,
00057 std::list<delta>* a=NULL, std::list<certificate>* b=NULL) const
00058 {
00059 const model* m = wn.get_model();
00060 unsigned int nvars(m->number_of_variables());
00061
00062 double diam=0.;
00063 double minw=COCO_INF;
00064 for(unsigned int i = 0; i < nvars; ++i)
00065 {
00066 double wdth(wn.node_ranges[m->var(i)->node_num].width());
00067 diam = std::max(diam, wdth);
00068 minw = std::min(minw, wdth);
00069 }
00070 dbr.add("diameter", diam);
00071 dbr.add("min width", minw);
00072 }
00073
00076 bool init_columns(vdbl::standard_table& stable)
00077 { bool ret = _init_column(stable, "diameter", 0.);
00078 ret = _init_column(stable, "min width", COCO_INF) || ret;
00079 return ret; }
00080
00083 bool drop_columns(vdbl::standard_table& stable)
00084 { return _drop_columns(stable); }
00085 };
00086
00087 }
00088
00089 #endif // _DIAMETER_HOOK_H