/Users/jamian/qecode-1.1/qecode/NaiveValueHeuristics.cc

Go to the documentation of this file.
00001 /*********************************************************[naivevalueheuristics.cc]
00002 Copyright (c) 2007, Universite d'Orleans - Jeremie Vautard, Marco Benedetti,
00003 Arnaud Lallouet.
00004 
00005 Permission is hereby granted, free of charge, to any person obtaining a copy
00006 of this software and associated documentation files (the "Software"), to deal
00007 in the Software without restriction, including without limitation the rights
00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00009 copies of the Software, and to permit persons to whom the Software is
00010 furnished to do so, subject to the following conditions:
00011 
00012 The above copyright notice and this permission notice shall be included in
00013 all copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00020 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00021 THE SOFTWARE.
00022 *****************************************************************************/
00023 
00024 
00025 #include "NaiveValueHeuristics.hh"
00026 
00027 int** SmallestValueFirst::subSet(Implicative* home,int var,int* nbRanges) {
00028     int zeValue = getVar(home,whichSpaceOwns(home,var),var)->min();
00029     *nbRanges = 1;
00030     int** ret = new int*[2];
00031     ret[0]=new int[1];
00032     ret[1]=new int[1];
00033     ret[0][0]=zeValue;
00034     ret[1][0]=zeValue;
00035     return ret;
00036 }
00037 
00038 int** LargestValueFirst::subSet(Implicative* home,int var,int* nbRanges) {
00039     int zeValue = getVar(home,whichSpaceOwns(home,var),var)->max();
00040     *nbRanges = 1;
00041     int** ret = new int*[2];
00042     ret[0]=new int[1];
00043     ret[1]=new int[1];
00044     ret[0][0]=zeValue;
00045     ret[1][0]=zeValue;
00046     return ret;
00047 }
00048 
00049 int** MedianValueFirst::subSet(Implicative* home,int var,int* nbRanges) {
00050     int zeValue = getVar(home,whichSpaceOwns(home,var),var)->med();
00051     *nbRanges = 1;
00052     int** ret = new int*[2];
00053     ret[0]=new int[1];
00054     ret[1]=new int[1];
00055     ret[0][0]=zeValue;
00056     ret[1][0]=zeValue;
00057     return ret;
00058 }
00059 
00060 int** SmallestHalfFirst::subSet(Implicative* home,int var,int* nbRanges) {
00061     int zeMin = getVar(home,whichSpaceOwns(home,var),var)->min();
00062     int zeMax = getVar(home,whichSpaceOwns(home,var),var)->med();
00063     int varMax = getVar(home,whichSpaceOwns(home,var),var)->max();
00064     if (zeMax == varMax) zeMax--;
00065     *nbRanges = 1;
00066     int** ret = new int*[2];
00067     ret[0]=new int[1];
00068     ret[1]=new int[1];
00069     ret[0][0]=zeMin;
00070     ret[1][0]=zeMax;
00071     return ret;
00072 }
00073 
00074 int** LargestHalfFirst::subSet(Implicative* home,int var,int* nbRanges) {
00075     int zeMin = getVar(home,whichSpaceOwns(home,var),var)->med();
00076     int zeMax = getVar(home,whichSpaceOwns(home,var),var)->max();
00077     int varMin = getVar(home,whichSpaceOwns(home,var),var)->min();
00078     if (zeMin == varMin) zeMin++;
00079     *nbRanges = 1;
00080     int** ret = new int*[2];
00081     ret[0]=new int[1];
00082     ret[1]=new int[1];
00083     ret[0][0]=zeMin;
00084     ret[1][0]=zeMax;
00085     return ret;
00086 }

Generated on Fri Sep 21 16:36:36 2007 for qecode by  doxygen 1.5.2