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 _PENDING_STATUS_HOOK_H
00029 #define _PENDING_STATUS_HOOK_H
00030
00031 #include <comp_hook.h>
00032 #include <int_evaluator.h>
00033
00034 namespace coco {
00035
00037
00044 class pending_status_comp_hook : public wnc_hook_base
00045 {
00046 public:
00048 pending_status_comp_hook() : wnc_hook_base("pending_status") {}
00049
00051 virtual ~pending_status_comp_hook() {}
00052
00054 pending_status_comp_hook* new_copy() const
00055 { return new pending_status_comp_hook(*this); }
00056
00059 void operator()(const work_node& wn, dbt_row& dbr,
00060 std::list<delta>* a=NULL, std::list<certificate>* b=NULL) const
00061 {
00062 const model* m = wn.get_model();
00063 unsigned int nvars(m->number_of_variables());
00064 variable_indicator vi(nvars);
00065 std::vector<interval> box(nvars, 0.);
00066 model::const_walker w;
00067 interval rg;
00068 double pending_status(0.);
00069
00070 vi.set(0,nvars);
00071
00072 for(unsigned int i = 0; i < nvars; ++i)
00073 box[i] = wn.node_ranges[m->var(i)->node_num];
00074 interval_eval ie(box, vi, *m, NULL, false);
00075
00076 for(model::const_ref_iterator _ci = m->constraints.begin();
00077 _ci != m->constraints.end(); ++_ci)
00078 {
00079 w = *_ci;
00080 rg = evaluate(ie, w);
00081 const interval &bds(w->f_bounds);
00082 if(bds.sup() < rg.inf() || rg.sup() < bds.inf())
00083 {
00084 pending_status = -COCO_INF;
00085 break;
00086 }
00087 if(!bds.contains(rg))
00088 {
00089 if(rg.sup() != bds.sup())
00090 pending_status += rg.sup() - bds.sup();
00091 if(rg.inf() != bds.inf())
00092 pending_status += bds.inf() - rg.inf();
00093 }
00094 }
00095
00096 dbr.add("pending status", pending_status);
00097 }
00098
00101 bool init_columns(vdbl::standard_table& stable)
00102 { return _init_column(stable, "pending status", COCO_INF); }
00103
00106 bool drop_columns(vdbl::standard_table& stable)
00107 { return _drop_columns(stable); }
00108 };
00109
00110 }
00111
00112 #endif // _PENDING_STATUS_HOOK_H