Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3415 for trunk


Ignore:
Timestamp:
04/19/10 20:49:12 (14 years ago)
Author:
mkofler
Message:

Worked on particle swarm optimization algorithm #852 (WIP)

Location:
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3.csproj

    r3384 r3415  
    8686    <Compile Include="PermutationToRealVectorEncoder.cs" />
    8787    <Compile Include="Properties\AssemblyInfo.cs" />
     88    <Compile Include="RealVectorToRealVectorEncoder.cs" />
    8889  </ItemGroup>
    8990  <ItemGroup>
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs

    r3376 r3415  
    4848      set { base.Problem = value; }
    4949    }
     50    public IRealVectorEncoder Encoder {
     51      get { return EncoderParameter.Value; }
     52      set { EncoderParameter.Value = value; }
     53    }
    5054    #endregion
    5155
     
    8488      Parameters.Add(new OptionalConstrainedValueParameter<IRealVectorEncoder>("Encoder", "The operator used to encode solutions as position vector."));
    8589      //Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    86 
    8790      RandomCreator randomCreator = new RandomCreator();
    8891      SolutionsCreator solutionsCreator = new SolutionsCreator();
     92      UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
     93      VariableCreator variableCreator = new VariableCreator();
     94      variableCreator.CollectedValues.Add(new ValueParameter<RealVector>("Velocity", new RealVector()));
    8995      //solutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreator.Name;
    90       mainLoop = new ParticleSwarmOptimizationMainLoop();
     96      //mainLoop = new ParticleSwarmOptimizationMainLoop();
    9197      OperatorGraph.InitialOperator = randomCreator;
    9298
     
    99105
    100106      solutionsCreator.NumberOfSolutionsParameter.ActualName = SwarmSizeParameter.Name;
    101       solutionsCreator.Successor = mainLoop;
     107      solutionsCreator.Successor = variableCreator;
     108      variableCreator.Successor = uniformSubScopesProcessor;
     109     
    102110
    103       mainLoop.EncoderParameter.ActualName = EncoderParameter.Name;
     111      //evaluator.Successor = mainLoop;
     112      //mainLoop.EncoderParameter.ActualName = EncoderParameter.Name;
    104113
    105114      Initialize();
    106115    }
    107116
     117    [StorableHook(HookType.AfterDeserialization)]
    108118    private void Initialize() {
    109      
     119      EncoderParameter.ValueChanged += new EventHandler(EncoderParameter_ValueChanged);
    110120    }
    111121
     
    136146      base.OnProblemChanged();
    137147    }
     148
     149    private void EncoderParameter_ValueChanged(object sender, EventArgs e) {
     150      ((UniformSubScopesProcessor)((SolutionsCreator)((RandomCreator)OperatorGraph.InitialOperator).Successor).Successor).Operator = EncoderParameter.Value;
     151    }
    138152    #endregion
    139153
     
    152166      }
    153167    }
     168
    154169    #endregion
    155170  }
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimizationMainLoop.cs

    r3376 r3415  
    2424      get { return (ValueLookupParameter<IOperator>)Parameters["Encoder"]; }
    2525    }
    26     public ValueLookupParameter<IOperator> EvaluatorParameter {
    27       get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
    28     }
     26    //public ValueLookupParameter<IOperator> EvaluatorParameter {
     27    //  get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
     28    //}
    2929    #endregion
    3030
     
    4040      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
    4141      Parameters.Add(new ValueLookupParameter<IOperator>("Encoder", "The encoding operator that maps a solution to a position vector."));
    42       Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
     42      //Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
    4343      #endregion
    4444
     
    5353      encoder.OperatorParameter.ActualName = EncoderParameter.Name;
    5454
    55       evaluator.Name = "Evaluator (placeholder)";
    56       evaluator.OperatorParameter.ActualName = EvaluatorParameter.Name;
     55      //evaluator.Name = "Evaluator (placeholder)";
     56      //evaluator.OperatorParameter.ActualName = EvaluatorParameter.Name;
    5757      #endregion
    5858
     
    6161      variableCreator.Successor = uniformSubScopesProcessor;
    6262      uniformSubScopesProcessor.Operator = encoder;
    63       uniformSubScopesProcessor.Successor = evaluator;
     63      //uniformSubScopesProcessor.Successor = evaluator;
    6464      #endregion
    6565    }
Note: See TracChangeset for help on using the changeset viewer.