2 #include "ActionNormal.h"
4 #include "normalizer.h"
11 ActionNormal::ActionNormal(model *m) {
13 domrelation=m->getdomainrelation();
16 void ActionNormal::repairpredicate(Hashtable *env,CoercePredicate *p) {
17 /* Don't actually repair stuff */
21 void ActionNormal::breakpredicate(Hashtable *env, CoercePredicate *p)
23 /* Don't actually break stuff */
27 bool ActionNormal::conflict(Constraint *c1, CoercePredicate *p1,Constraint *c2, CoercePredicate *p2) {
30 /* Compute bounding set if there is one */
31 char *boundname=p1->getltype();
32 /* Check conflicts arrising from addition to set */
34 WorkSet *ws=domrelation->conflictaddsets(p1->getrelset(),boundname,globalmodel);
35 DomainSet *ds=(DomainSet *) ws->firstelement();
37 if (conflictwithaddtoset(ds->getname(),c2,p2)) {
41 ds=(DomainSet *) ws->getnextelement(ds);
45 /* Check conflicts arrising from deletions from set */
47 WorkSet *ws=domrelation->conflictdelsets(p1->getrelset(), boundname);
48 DomainSet *ds=(DomainSet *) ws->firstelement();
50 if (conflictwithremovefromset(NULL,ds->getname(),c2,p2)) {
54 ds=(DomainSet *) ws->getnextelement(ds);
65 /* Compute bounding set if there is one */
66 char *boundname=getset(c1,p1->getrtype());
67 DomainRelation *drel=globalmodel->getdomainrelation();
68 char *insertset=drel->getrelation(p1->getrelset())->getrange();
70 /* Check conflicts arrising from addition to set */
72 WorkSet *ws=domrelation->conflictaddsets(insertset,boundname,globalmodel);
73 DomainSet *ds=(DomainSet *) ws->firstelement();
75 if (conflictwithaddtoset(ds->getname(),c2,p2)) {
79 ds=(DomainSet *) ws->getnextelement(ds);
83 /* Check conflicts arrising from deletions from set */
85 WorkSet *ws=domrelation->conflictdelsets(insertset, boundname);
86 DomainSet *ds=(DomainSet *) ws->firstelement();
88 if (conflictwithremovefromset(NULL,ds->getname(),c2,p2)) {
92 ds=(DomainSet *) ws->getnextelement(ds);
97 /* Compute bounding set if there is one */
98 char *boundname=getset(c1,p1->getltype());
99 DomainRelation *drel=globalmodel->getdomainrelation();
100 char *insertset=drel->getrelation(p1->getrelset())->getdomain();
102 /* Check conflicts arrising from addition to set */
104 WorkSet *ws=domrelation->conflictaddsets(insertset,boundname,globalmodel);
105 DomainSet *ds=(DomainSet *) ws->firstelement();
107 if (conflictwithaddtoset(ds->getname(),c2,p2)) {
111 ds=(DomainSet *) ws->getnextelement(ds);
115 /* Check conflicts arrising from deletions from set */
117 WorkSet *ws=domrelation->conflictdelsets(insertset, boundname);
118 DomainSet *ds=(DomainSet *) ws->firstelement();
120 if (conflictwithremovefromset(NULL,ds->getname(),c2,p2)) {
124 ds=(DomainSet *) ws->getnextelement(ds);
129 /* we have a in v.r */
131 return testforconflict(getset(c1,p1->getltype()),
132 getset(c1,p1->getrtype()),
133 p1->getrelset(),c2,p2);
138 bool ActionNormal::canrepairpredicate(CoercePredicate *cp) {
139 return false; /* Doesn't repair stuff */