Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/30/09 19:41:58 (15 years ago)
Author:
gkronber
Message:

GP Refactoring #713

  • cleaned code
  • reintegrated GP.Boolean and GP.SantaFe
  • worked on serialization of function trees
Location:
branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3
Files:
2 added
5 edited
8 moved

Legend:

Unmodified
Added
Removed
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/BooleanTreeInterpreter.cs

    r2174 r2216  
    2424using System.Linq;
    2525using System.Text;
    26 using HeuristicLab.DataAnalysis;
    2726using HeuristicLab.Core;
    2827using System.Xml;
    2928using System.Diagnostics;
    3029using HeuristicLab.Data;
     30using HeuristicLab.GP.Interfaces;
     31using HeuristicLab.DataAnalysis;
    3132
    3233namespace HeuristicLab.GP.Boolean {
     
    3435    private const double EPSILON = 0.00001;
    3536    private Dataset dataset;
    36     private List<LightWeightFunction> expression;
     37    private IFunctionTree tree;
    3738    private int targetVariable;
    3839    private int currentRow;
    39     private int pc;
    4040
    41     public void Reset(Dataset dataset, BakedFunctionTree tree, int targetVariable) {
     41    public void Reset(Dataset dataset, IFunctionTree tree, int targetVariable) {
    4242      this.dataset = dataset;
    43       this.expression = tree.LinearRepresentation;
     43      this.tree = tree;
    4444      this.targetVariable = targetVariable;
    4545    }
     
    4848      int errors = 0;
    4949      for (int i = start; i < end; i++) {
    50         pc = 0;
    5150        currentRow = i;
    52         int result = Step() ? 1 : 0;
     51        int result = Step(tree) ? 1 : 0;
    5352        if (Math.Abs(result - dataset.GetValue(i, targetVariable)) > EPSILON) errors++;
    5453      }
     
    5655    }
    5756
    58     internal bool Step() {
    59       LightWeightFunction curFun = expression[pc++];
    60       int symbol = SymbolTable.MapFunction(curFun.functionType);
     57    internal bool Step(IFunctionTree t) {
     58      int symbol = SymbolTable.MapFunction(t.Function);
    6159      switch (symbol) {
    62         case SymbolTable.AND: return Step() & Step();
    63         case SymbolTable.OR: return Step() | Step();
    64         case SymbolTable.NOT: return !Step();
    65         case SymbolTable.XOR: return Step() ^ Step();
    66         case SymbolTable.NAND: return !(Step() & Step());
    67         case SymbolTable.NOR: return !(Step() | Step());
    68         case SymbolTable.VARIABLE:
    69           return dataset.GetValue(currentRow, (int)curFun.localData[0]) != 0.0;
     60        case SymbolTable.AND: return Step(t.SubTrees[0]) && Step(t.SubTrees[1]);
     61        case SymbolTable.OR: return Step(t.SubTrees[0]) || Step(t.SubTrees[1]);
     62        case SymbolTable.NOT: return !Step(t.SubTrees[0]);
     63        case SymbolTable.XOR: return Step(t.SubTrees[0]) ^ Step(t.SubTrees[1]);
     64        case SymbolTable.NAND: return !(Step(t.SubTrees[0]) && Step(t.SubTrees[1]));
     65        case SymbolTable.NOR: return !(Step(t.SubTrees[0]) || Step(t.SubTrees[1]));
     66        case SymbolTable.VARIABLE: {
     67            var varNode = (VariableFunctionTree)t;
     68            int index = dataset.GetVariableIndex(varNode.VariableName);
     69            return !IsAlmost(dataset.GetValue(currentRow, index), 0.0);
     70          }
    7071        case SymbolTable.UNKNOWN:
    7172        default:
    72           throw new InvalidOperationException(curFun.functionType.ToString());
     73          throw new UnknownFunctionException(t.Function.Name);
     74      }
     75    }
    7376
    74       }
     77    private bool IsAlmost(double x, double y) {
     78      return Math.Abs(x - y) < EPSILON;
    7579    }
    7680  }
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/Evaluator.cs

    r1529 r2216  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
     28using HeuristicLab.GP.Interfaces;
    2829using HeuristicLab.DataAnalysis;
    2930
     
    3233    public Evaluator()
    3334      : base() {
    34       AddVariableInfo(new VariableInfo("FunctionTree", "The function tree representing the ant", typeof(BakedFunctionTree), VariableKind.In));
     35      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree representing the boolean expression to evaluate", typeof(IGeneticProgrammingModel), VariableKind.In));
    3536      AddVariableInfo(new VariableInfo("Dataset", "The boolean dataset (values 0.0 = false, 1.0=true)", typeof(Dataset), VariableKind.In));
    3637      AddVariableInfo(new VariableInfo("TargetVariable", "Index of the column of the dataset that holds the target variable", typeof(IntData), VariableKind.In));
     
    4142
    4243    public override IOperation Apply(IScope scope) {
    43       BakedFunctionTree tree = GetVariableValue<BakedFunctionTree>("FunctionTree", scope, true);
     44      IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, true);
    4445      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
    4546      int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
     
    4849
    4950      BooleanTreeInterpreter interpreter = new BooleanTreeInterpreter();
    50       interpreter.Reset(dataset, tree, targetVariable);
     51      interpreter.Reset(dataset, gpModel.FunctionTree, targetVariable);
    5152      int errors = interpreter.GetNumberOfErrors(start, end);
    5253
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/FunctionLibraryInjector.cs

    r2202 r2216  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.DataAnalysis;
    29 using HeuristicLab.Constraints;
     29using HeuristicLab.GP.Interfaces;
     30using HeuristicLab.GP.SantaFe;
    3031
    3132namespace HeuristicLab.GP.Boolean {
    32   public class FunctionLibraryInjector : OperatorBase {
    33     private const string TARGETVARIABLE = "TargetVariable";
    34     private const string OPERATORLIBRARY = "FunctionLibrary";
    35 
    36     private FunctionLibrary operatorLibrary;
    37     private Variable variable;
    38 
     33  public class FunctionLibraryInjector : FunctionLibraryInjectorBase {
    3934    public override string Description {
    4035      get { return @"Injects a function library for boolean logic."; }
     
    4338    public FunctionLibraryInjector()
    4439      : base() {
    45       AddVariableInfo(new VariableInfo(TARGETVARIABLE, "The target variable", typeof(IntData), VariableKind.In));
    46       AddVariableInfo(new VariableInfo(OPERATORLIBRARY, "Preconfigured default operator library", typeof(FunctionLibrary), VariableKind.New));
    4740    }
    4841
    49     public override IOperation Apply(IScope scope) {
    50       int targetVariable = GetVariableValue<IntData>(TARGETVARIABLE, scope, true).Data;
    51 
    52       InitDefaultOperatorLibrary();
    53 
    54       scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(OPERATORLIBRARY), operatorLibrary));
    55       return null;
    56     }
    57 
    58     private void InitDefaultOperatorLibrary() {
     42    protected override FunctionLibrary CreateFunctionLibrary() {
    5943      And and = new And();
    6044      Or or = new Or();
    61       //Not not = new Not();
     45      Not not = new Not();
    6246      Nand nand = new Nand();
    6347      Nor nor = new Nor();
    64       //Xor xor = new Xor();
    65       variable = new HeuristicLab.GP.Boolean.Variable();
     48      Xor xor = new Xor();
     49      Variable variable = new Variable();
    6650
    6751      IFunction[] allFunctions = new IFunction[] {
    6852        and,
    6953        or,
    70         //not,
     54        not,
    7155        nand,
    7256        nor,
    73         //xor,
     57        xor,
    7458        variable
    7559      };
     
    7761      SetAllowedSubOperators(and, allFunctions);
    7862      SetAllowedSubOperators(or, allFunctions);
    79       //SetAllowedSubOperators(not, allFunctions);
     63      SetAllowedSubOperators(not, allFunctions);
    8064      SetAllowedSubOperators(nand, allFunctions);
    8165      SetAllowedSubOperators(nor, allFunctions);
    82       //SetAllowedSubOperators(xor, allFunctions);
     66      SetAllowedSubOperators(xor, allFunctions);
    8367
    84       operatorLibrary = new FunctionLibrary();
    85       operatorLibrary.FunctionGroup.AddFunction(and);
    86       operatorLibrary.FunctionGroup.AddFunction(or);
    87       //operatorLibrary.GPOperatorGroup.AddOperator(not);
    88       operatorLibrary.FunctionGroup.AddFunction(nand);
    89       operatorLibrary.FunctionGroup.AddFunction(nor);
    90       //operatorLibrary.GPOperatorGroup.AddOperator(xor);
    91       operatorLibrary.FunctionGroup.AddFunction(variable);
    92     }
    93 
    94     private void SetAllowedSubOperators(IFunction f, IFunction[] gs) {
    95       foreach (IConstraint c in f.Constraints) {
    96         if (c is SubOperatorTypeConstraint) {
    97           SubOperatorTypeConstraint typeConstraint = c as SubOperatorTypeConstraint;
    98           typeConstraint.Clear();
    99           foreach (IFunction g in gs) {
    100             typeConstraint.AddOperator(g);
    101           }
    102         } else if (c is AllSubOperatorsTypeConstraint) {
    103           AllSubOperatorsTypeConstraint typeConstraint = c as AllSubOperatorsTypeConstraint;
    104           typeConstraint.Clear();
    105           foreach (IFunction g in gs) {
    106             typeConstraint.AddOperator(g);
    107           }
    108         }
    109       }
     68      var functionLibrary = new FunctionLibrary();
     69      functionLibrary.AddFunction(and);
     70      functionLibrary.AddFunction(or);
     71      functionLibrary.AddFunction(not);
     72      functionLibrary.AddFunction(nand);
     73      functionLibrary.AddFunction(nor);
     74      functionLibrary.AddFunction(xor);
     75      functionLibrary.AddFunction(variable);
     76      return functionLibrary;
    11077    }
    11178  }
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/HeuristicLab.GP.Boolean-3.3.csproj

    r1534 r2216  
    8181  <ItemGroup>
    8282    <Compile Include="BooleanTreeInterpreter.cs" />
    83     <Compile Include="Not.cs" />
    84     <Compile Include="Xor.cs" />
    85     <Compile Include="Or.cs" />
    86     <Compile Include="Nand.cs" />
    87     <Compile Include="Nor.cs" />
     83    <Compile Include="Symbols\And.cs" />
     84    <Compile Include="Symbols\Nand.cs" />
     85    <Compile Include="Symbols\Nor.cs" />
     86    <Compile Include="Symbols\Not.cs" />
     87    <Compile Include="Symbols\Or.cs" />
     88    <Compile Include="Symbols\SymbolTable.cs" />
     89    <Compile Include="Symbols\Variable.cs" />
     90    <Compile Include="Symbols\VariableFunctionTree.cs" />
     91    <Compile Include="Symbols\Xor.cs" />
    8892    <Compile Include="Evaluator.cs" />
    8993    <Compile Include="FunctionLibraryInjector.cs" />
    9094    <Compile Include="HeuristicLabGPBooleanPlugin.cs" />
    91     <Compile Include="And.cs" />
    92     <Compile Include="Variable.cs" />
    9395    <Compile Include="Properties\AssemblyInfo.cs" />
    94     <Compile Include="SymbolTable.cs" />
    9596  </ItemGroup>
    9697  <ItemGroup>
     
    99100  </ItemGroup>
    100101  <ItemGroup>
    101     <ProjectReference Include="..\..\HeuristicLab.Constraints\3.2\HeuristicLab.Constraints-3.2.csproj">
    102       <Project>{FCD62C6F-4793-4593-AE9A-0BDCA256EE99}</Project>
    103       <Name>HeuristicLab.Constraints-3.2</Name>
    104     </ProjectReference>
    105102    <ProjectReference Include="..\..\HeuristicLab.Core\3.2\HeuristicLab.Core-3.2.csproj">
    106103      <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project>
     
    114111      <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project>
    115112      <Name>HeuristicLab.Data-3.2</Name>
     113    </ProjectReference>
     114    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
     115      <Project>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</Project>
     116      <Name>HeuristicLab.GP.Interfaces-3.3</Name>
    116117    </ProjectReference>
    117118    <ProjectReference Include="..\..\HeuristicLab.GP\3.3\HeuristicLab.GP-3.3.csproj">
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/HeuristicLabGPBooleanPlugin.cs

    r1529 r2216  
    2828  [ClassInfo(Name = "HeuristicLab.GP.Boolean-3.3")]
    2929  [PluginFile(Filename = "HeuristicLab.GP.Boolean-3.3.dll", Filetype = PluginFileType.Assembly)]
    30   [Dependency(Dependency = "HeuristicLab.Constraints-3.2")]
    31   [Dependency(Dependency = "HeuristicLab.GP-3.3")]
    3230  [Dependency(Dependency = "HeuristicLab.Core-3.2")]
    3331  [Dependency(Dependency = "HeuristicLab.Data-3.2")]
    3432  [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")]
     33  [Dependency(Dependency = "HeuristicLab.GP-3.3")]
     34  [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")]
    3535  [Dependency(Dependency = "HeuristicLab.Operators-3.2")]
    3636  [Dependency(Dependency = "HeuristicLab.Random-3.2")]
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/Symbols/And.cs

    r2211 r2216  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using HeuristicLab.Data;
    26 using HeuristicLab.Core;
    27 using System.Xml;
    28 using HeuristicLab.Constraints;
    29 using HeuristicLab.DataAnalysis;
    3022
    3123namespace HeuristicLab.GP.Boolean{
    32   public sealed class And : FunctionBase {
    33 
    34     public override string Description {
    35       get { return ""; }
    36     }
    37 
    38     public And()
    39       : base() {
    40       MinArity = 2; MaxArity = 2;
    41     }
     24  public sealed class And : BinaryFunction {
    4225  }
    4326}
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/Symbols/Nand.cs

    r2211 r2216  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using HeuristicLab.Data;
    26 using HeuristicLab.Core;
    27 using System.Xml;
    28 using HeuristicLab.Constraints;
    29 using HeuristicLab.DataAnalysis;
    3022
    3123namespace HeuristicLab.GP.Boolean{
    32   public sealed class Nand : FunctionBase {
    33 
    34     public override string Description {
    35       get { return ""; }
    36     }
    37 
    38     public Nand()
    39       : base() {
    40       MinArity = 2; MaxArity = 2;
    41     }
     24  public sealed class Nand : BinaryFunction {
    4225  }
    4326}
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/Symbols/Nor.cs

    r2211 r2216  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using HeuristicLab.Data;
    26 using HeuristicLab.Core;
    27 using System.Xml;
    28 using HeuristicLab.Constraints;
    29 using HeuristicLab.DataAnalysis;
    30 
    3122namespace HeuristicLab.GP.Boolean{
    32   public sealed class Nor : FunctionBase {
    33 
    34     public override string Description {
    35       get { return ""; }
    36     }
    37 
    38     public Nor()
    39       : base() {
    40       MinArity = 2; MaxArity = 2;
    41     }
     23  public sealed class Nor : BinaryFunction {
    4224  }
    4325}
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/Symbols/Not.cs

    r2211 r2216  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using HeuristicLab.Data;
    26 using HeuristicLab.Core;
    27 using System.Xml;
    28 using HeuristicLab.Constraints;
    29 using HeuristicLab.DataAnalysis;
    30 
    3122namespace HeuristicLab.GP.Boolean{
    32   public sealed class Not : FunctionBase {
    33 
    34     public override string Description {
    35       get { return ""; }
    36     }
    37 
    38     public Not()
    39       : base() {
    40       MinArity = 1; MaxArity = 1;
    41     }
     23  public sealed class Not : UnaryFunction {
    4224  }
    4325}
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/Symbols/Or.cs

    r2211 r2216  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using HeuristicLab.Data;
    26 using HeuristicLab.Core;
    27 using System.Xml;
    28 using HeuristicLab.Constraints;
    29 using HeuristicLab.DataAnalysis;
    30 
    3122namespace HeuristicLab.GP.Boolean{
    32   public sealed class Or : FunctionBase {
    33 
    34     public override string Description {
    35       get { return ""; }
    36     }
    37 
    38     public Or()
    39       : base() {
    40       MinArity = 2; MaxArity = 2;
    41     }
     23  public sealed class Or : BinaryFunction {
    4224  }
    4325}
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/Symbols/SymbolTable.cs

    r2211 r2216  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
    2624using HeuristicLab.Core;
    27 using System.Xml;
     25using HeuristicLab.GP.Interfaces;
    2826
    2927namespace HeuristicLab.GP.Boolean {
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/Symbols/Variable.cs

    r2211 r2216  
    2626using HeuristicLab.Core;
    2727using System.Xml;
    28 using HeuristicLab.Constraints;
    29 using HeuristicLab.DataAnalysis;
    3028using HeuristicLab.Operators;
    3129using HeuristicLab.Random;
    3230
    3331namespace HeuristicLab.GP.Boolean {
    34   public sealed class Variable : FunctionBase {
    35     public const string INDEX = "Variable";
    36 
    37     private int minIndex;
    38     private int maxIndex;
    39 
    40     public override string Description {
    41       get { return ""; }
    42     }
     32  public sealed class Variable : Terminal {
     33    public const string VARIABLENAME = "Variable";
    4334
    4435    public Variable()
    4536      : base() {
    46       AddVariableInfo(new VariableInfo(INDEX, "Index of the variable in the dataset representing this feature", typeof(ConstrainedIntData), VariableKind.None));
    47       GetVariableInfo(INDEX).Local = true;
    48       AddVariableInfo(new VariableInfo(INITIALIZATION, "Initialization operator for variables", typeof(CombinedOperator), VariableKind.None));
    49       GetVariableInfo(INITIALIZATION).Local = false;
    50       AddVariableInfo(new VariableInfo(MANIPULATION, "Manipulation operator for variables", typeof(CombinedOperator), VariableKind.None));
    51       GetVariableInfo(MANIPULATION).Local = false;
    52 
    53       MinArity = 0; MaxArity = 0;
    54 
    55       ConstrainedIntData variable = new ConstrainedIntData();
    56       AddVariable(new HeuristicLab.Core.Variable(INDEX, variable));
    57       minIndex = 0; maxIndex = 100;
    58 
    5937      SetupInitialization();
    6038      SetupManipulation();
     39    }
    6140
     41    public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() {
     42      return new VariableFunctionTree(this);
    6243    }
    6344
     
    6546      CombinedOperator combinedOp = new CombinedOperator();
    6647      SequentialProcessor seq = new SequentialProcessor();
    67       UniformRandomizer indexRandomizer = new UniformRandomizer();
    68       indexRandomizer.Min = minIndex;
    69       indexRandomizer.Max = maxIndex + 1; // uniform randomizer generates numbers in the range [min, max[
    70       indexRandomizer.GetVariableInfo("Value").ActualName = INDEX;
    71       indexRandomizer.Name = "Index Randomizer";
     48      UniformItemChooser variableRandomizer = new UniformItemChooser();
     49      variableRandomizer.GetVariableInfo("Value").ActualName = VARIABLENAME;
     50      variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables";
     51      variableRandomizer.Name = "Variable randomizer";
    7252
    7353      combinedOp.OperatorGraph.AddOperator(seq);
    74       combinedOp.OperatorGraph.AddOperator(indexRandomizer);
     54      combinedOp.OperatorGraph.AddOperator(variableRandomizer);
    7555      combinedOp.OperatorGraph.InitialOperator = seq;
    76       seq.AddSubOperator(indexRandomizer);
     56      seq.AddSubOperator(variableRandomizer);
    7757      Initializer = combinedOp;
    7858    }
     
    8262      CombinedOperator combinedOp = new CombinedOperator();
    8363      SequentialProcessor seq = new SequentialProcessor();
    84       UniformRandomizer indexRandomizer = new UniformRandomizer();
    85       indexRandomizer.Min = minIndex;
    86       indexRandomizer.Max = maxIndex + 1;
    87       indexRandomizer.GetVariableInfo("Value").ActualName = INDEX;
    88       indexRandomizer.Name = "Index Randomizer";
     64      UniformItemChooser variableRandomizer = new UniformItemChooser();
     65      variableRandomizer.GetVariableInfo("Value").ActualName = VARIABLENAME;
     66      variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables";
     67      variableRandomizer.Name = "Variable randomizer";
    8968
    9069      combinedOp.OperatorGraph.AddOperator(seq);
    91       combinedOp.OperatorGraph.AddOperator(indexRandomizer);
     70      combinedOp.OperatorGraph.AddOperator(variableRandomizer);
    9271      combinedOp.OperatorGraph.InitialOperator = seq;
    93       seq.AddSubOperator(indexRandomizer);
     72      seq.AddSubOperator(variableRandomizer);
    9473      Manipulator = combinedOp;
    95     }
    96 
    97     public void SetConstraints(int[] allowedIndexes) {
    98       //ConstrainedIntData index = GetVariableValue<ConstrainedIntData>(INDEX, null, false);
    99       Array.Sort(allowedIndexes);
    100       minIndex = allowedIndexes[0]; maxIndex = allowedIndexes[allowedIndexes.Length - 1];
    101       List<IConstraint> constraints = new List<IConstraint>();
    102       int start = allowedIndexes[0];
    103       int prev = start;
    104       for(int i = 1; i < allowedIndexes.Length; i++) {
    105         if(allowedIndexes[i] != prev + 1) {
    106           IntBoundedConstraint lastRange = new IntBoundedConstraint();
    107           lastRange.LowerBound = start;
    108           lastRange.LowerBoundEnabled = true;
    109           lastRange.LowerBoundIncluded = true;
    110           lastRange.UpperBound = prev;
    111           lastRange.UpperBoundEnabled = true;
    112           lastRange.UpperBoundIncluded = true;
    113           constraints.Add(lastRange);
    114           start = allowedIndexes[i];
    115           prev = start;
    116         }
    117         prev = allowedIndexes[i];
    118       }
    119       IntBoundedConstraint range = new IntBoundedConstraint();
    120       range.LowerBound = start;
    121       range.LowerBoundEnabled = true;
    122       range.LowerBoundIncluded = true;
    123       range.UpperBound = prev;
    124       range.UpperBoundEnabled = true;
    125       range.UpperBoundIncluded = true;
    126       constraints.Add(range);
    127       if(constraints.Count > 1) {
    128         OrConstraint or = new OrConstraint();
    129         foreach(IConstraint c in constraints) or.Clauses.Add(c);
    130         index.AddConstraint(or);
    131       } else {
    132         index.AddConstraint(constraints[0]);
    133       }
    134 
    135       SetupInitialization();
    136       SetupManipulation();
    13774    }
    13875  }
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP.Boolean/3.3/Symbols/Xor.cs

    r2211 r2216  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using HeuristicLab.Data;
    26 using HeuristicLab.Core;
    27 using System.Xml;
    28 using HeuristicLab.Constraints;
    29 using HeuristicLab.DataAnalysis;
    30 
    3122namespace HeuristicLab.GP.Boolean{
    32   public sealed class Xor : FunctionBase {
    33 
    34     public override string Description {
    35       get { return ""; }
    36     }
    37 
    38     public Xor()
    39       : base() {
    40       MinArity = 2; MaxArity = 2;
    41     }
     23  public sealed class Xor : BinaryFunction {
    4224  }
    4325}
Note: See TracChangeset for help on using the changeset viewer.