/**** , [ QCOPPlus.cc ], Copyright (c) 2009 Universite d'Orleans - Jeremie Vautard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *************************************************************************/ #include "QCOPPlus.hh" Qcop::Qcop(int ns, bool* quant, int* nv) { n=0; this->nvar = nv; for (int i=0;iv[var] = new IntVar(*rules[i],min,max); rules[i]->type_of_v[var] = VTYPE_INT; } goal->v[var] = new IntVar(*goal,min,max); goal->type_of_v[var] = VTYPE_INT; varInitialised[var]=true; type_of_v[var]=VTYPE_INT; } void Qcop::QIntVar(int var,IntSet dom) { if (varInitialised[var]) { cout<<"Variable "<v[var] = new IntVar(*rules[i],dom); rules[i]->type_of_v[var] = VTYPE_INT; } goal->v[var] = new IntVar(*goal,dom); goal->type_of_v[var] = VTYPE_INT; varInitialised[var]=true; type_of_v[var]=VTYPE_INT; } void Qcop::QBoolVar(int var) { if (varInitialised[var]) { cout<<"Variable "<v[var] = new BoolVar(*rules[i],0,1); rules[i]->type_of_v[var]=VTYPE_BOOL; } goal->v[var] = new BoolVar(*goal,0,1); goal->type_of_v[var]=VTYPE_BOOL; varInitialised[var]=true; type_of_v[var]=VTYPE_BOOL; } MySpace* Qcop::space() { if (currentDeclareSpace(space()->v[n])); } BoolVar Qcop::bvar(int n) { if (!varInitialised[n]) { cout<<"Variable "<(space()->v[n])); } int Qcop::nextScope() { if (currentDeclareSpace == -1) return -1; currentDeclareSpace++; if (currentDeclareSpace>nbSpaces) return -1; return currentDeclareSpace; } void Qcop::makeStructure() { for (unsigned int i=0;inbSpaces;i++) { if (rules[i]->status() == SS_FAILED) { cout<<"MakeStructure : rule space "<status() == SS_FAILED) { cout<<"MakeStructure : goal space is already failed."<getScope() < scope) {cout<<"aggregated variable out of aggregator scope"<getScope();i++) // Universelle entre aggregateur et variable aggrŽgŽe if (Quantifiers[i]) {cout<<"Universal scope between variable and aggregator"<getScope() < scope) {cout<<"optvar out of optimizing scope"<getScope();i++) { if (Quantifiers[i]) // universelle entre variable et dŽcideur { cout<<"universal scope between variable and optimizing scope"<nbSpaces) { cout<<"I return NULL coz of bad scope value (<0)"<status() == SS_FAILED) { cout<<"I return NULL coz goal is failed"<(goal->clone()); } if (rules[scope]->status() == SS_FAILED) { cout<<"I return NULL coz scope "<(rules[scope]->clone())); } MySpace* Qcop::getGoal() { if (goal->status() == SS_FAILED) return NULL; return static_cast(goal->clone()); } int Qcop::getOptType(int scope) { if (Quantifiers[scope]) {cout<<"Try to get OptType on universal scope"<(optim[scope].vars[0]); } Qcop* Qcop::clone() { bool* qt = new bool[nbSpaces]; int* nvv = new int[nbSpaces]; MySpace** zerulz = new MySpace*[nbSpaces]; Opts* opop = new Opts[nbSpaces]; int* nbvbs = new int[nbSpaces]; for (unsigned int i=0;i < nbSpaces;i++) { qt[i] = this->Quantifiers[i]; nvv[i] = this->nvar[i]; zerulz[i] = static_cast(this->rules[i]->clone(false)); opop[i] = this->optim[i]; nbvbs[i] = this->nbVarBySpace[i]; } // void** v = new void*[this->n]; VarType* typeofv = new VarType[n]; int* wso = new int[n]; for (unsigned int i=0;itype_of_v[i]; wso[i] = this->whichSpaceOwns[i]; } Qcop* ret = new Qcop(); ret->nvar = nvv; ret->n = this->n; ret->nbSpaces = this->nbSpaces; ret->type_of_v = typeofv; ret->Quantifiers = qt; ret->rules = zerulz; ret->goal = static_cast(this->goal->clone(false)); ret->optim = opop; ret->nbVarBySpace = nbvbs; ret->whichSpaceOwns = wso; ret->varInitialised = this->varInitialised; currentDeclareSpace = this->currentDeclareSpace; return ret; }