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 _OBJBOUNDS_HOOK_H
00029 #define _OBJBOUNDS_HOOK_H
00030
00031 #include <comp_hook.h>
00032 #include <int_evaluator.h>
00033 #include <bound_delta.h>
00034
00035 namespace coco {
00036
00038
00046 class objbounds_comp_hook : public wnc_hook_base
00047 {
00048 private:
00049 bool update_bounds;
00050 bool create_delta;
00051
00052 public:
00054 objbounds_comp_hook(bool _ub = false, bool _cd = false)
00055 : wnc_hook_base("objbounds"),
00056 update_bounds(_ub), create_delta(_cd)
00057 {}
00058
00060 virtual ~objbounds_comp_hook() {}
00061
00063 objbounds_comp_hook* new_copy() const
00064 { return new objbounds_comp_hook(*this); }
00065
00069 void operator()(const work_node& wn, dbt_row& dbr,
00070 std::list<delta>* add_ds = NULL,
00071 std::list<certificate>* add_cs = NULL) const
00072 {
00073 const model* m = wn.get_model();
00074 model::const_walker w(m->objective);
00075 interval _h(0.);
00076 double _s;
00077
00078 if(m->ocoeff != 0)
00079 {
00080 if(update_bounds)
00081 {
00082 unsigned int nvars(m->number_of_variables());
00083 variable_indicator vi(nvars);
00084 std::vector<interval> box(nvars, 0.);
00085 interval rg;
00086
00087 vi.set(0,nvars);
00088
00089 for(unsigned int i = 0; i < nvars; ++i)
00090 box[i] = wn.node_ranges[m->var(i)->node_num];
00091 interval_eval ie(box, vi, *m, NULL, true);
00092
00093 _h = evaluate(ie, w)*m->ocoeff;
00094 _h.intersectwith(wn.node_ranges[w->node_num]);
00095 }
00096 else
00097 _h = wn.node_ranges[w->node_num];
00098
00099 if(update_bounds && create_delta && add_ds && add_cs &&
00100 _h != wn.node_ranges[w->node_num])
00101 {
00102 (*add_ds).push_back(delta(bound_delta(w->node_num, _h)));
00103 (*add_cs).push_back(
00104 certificate(rigorous_module_certificate("objbounds_hook")));
00105 }
00106
00107 _s = m->ocoeff;
00108 _h *= _s;
00109 }
00110 else
00111 _h = 0;
00112
00113 dbr.add("obj lowbound", _h.inf());
00114 dbr.add("obj upbound", _h.sup());
00115 dbr.add("obj diameter", _h.diam());
00116 }
00117
00120 bool init_columns(vdbl::standard_table& stable)
00121 {
00122 bool ret = _init_column(stable, "obj lowbound", -COCO_INF);
00123 ret = _init_column(stable, "obj upbound", COCO_INF) || ret;
00124 ret = _init_column(stable, "obj diameter", COCO_INF) || ret;
00125 return ret;
00126 }
00127
00130 bool drop_columns(vdbl::standard_table& stable)
00131 { return _drop_columns(stable); }
00132 };
00133
00134 }
00135
00136 #endif // _OBJBOUNDS_HOOK_H