Пример #1
0
        private void AfterDeserialization()
        {
            // BackwardsCompatibility3.3
            #region Backwards compatible code, remove with 3.4
            if (!Parameters.ContainsKey("ReevaluateElites"))
            {
                Parameters.Add(new FixedValueParameter <BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue) new BoolValue(false).AsReadOnly())
                {
                    Hidden = true
                });
            }
            if (Parameters.ContainsKey("SimilarityCalculator") && Parameters["SimilarityCalculator"] is IConstrainedValueParameter <ISingleObjectiveSolutionSimilarityCalculator> )
            {
#pragma warning disable 0618
                var oldParameter = (IConstrainedValueParameter <ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"];
#pragma warning restore 0618
                Parameters.Remove(oldParameter);
                var newParameter = new ConstrainedValueParameter <ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.", new ItemSet <ISolutionSimilarityCalculator>(oldParameter.ValidValues));
                var selectedSimilarityCalculator = newParameter.ValidValues.SingleOrDefault(x => x.GetType() == oldParameter.Value.GetType());
                newParameter.Value = selectedSimilarityCalculator;
                Parameters.Add(newParameter);
            }
            #endregion
            Initialize();
        }
Пример #2
0
        public virtual void AddEncoding(IEncoding encoding)
        {
            if (Parameters.ContainsKey(encoding.Name))
            {
                throw new ArgumentException(string.Format("Encoding {0} was already added.", encoding.Name));
            }

            encodings.Add(encoding);
            encoding.OperatorsChanged += Encoding_OperatorsChanged;

            var param = new ConstrainedValueParameter <T>(encoding.Name, new ItemSet <T>(encoding.Operators.OfType <T>()));

            param.Value = param.ValidValues.First();
            Parameters.Add(param);
        }
Пример #3
0
        private void AfterDeserialization()
        {
            // BackwardsCompatibility3.3
            #region Backwards compatible code, remove with 3.4
#pragma warning disable 0618
            if (Parameters.ContainsKey("SimilarityCalculator") && Parameters["SimilarityCalculator"] is IConstrainedValueParameter <ISingleObjectiveSolutionSimilarityCalculator> )
            {
                var oldParameter = (IConstrainedValueParameter <ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"];
#pragma warning restore 0618
                Parameters.Remove(oldParameter);
                var newParameter = new ConstrainedValueParameter <ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.", new ItemSet <ISolutionSimilarityCalculator>(oldParameter.ValidValues));
                var selectedSimilarityCalculator = newParameter.ValidValues.SingleOrDefault(x => x.GetType() == oldParameter.Value.GetType());
                newParameter.Value = selectedSimilarityCalculator;
                Parameters.Add(newParameter);
            }
            #endregion
            Initialize();
        }
Пример #4
0
 private void AfterDeserialization()
 {
     foreach (var encoding in encodings)
     {
         // BackwardsCompatibility3.3
         #region Backwards compatible code, remove with 3.4
         if (Parameters.ContainsKey(encoding.Name) && !Parameters.ContainsKey(OperatorPrefix + "." + encoding.Name))
         {
             var oldParam = (IConstrainedValueParameter <T>)Parameters[encoding.Name];
             var selected = oldParam.Value;
             Parameters.Remove(oldParam);
             var newParam = new ConstrainedValueParameter <T>(OperatorPrefix + "." + encoding.Name, new ItemSet <T>(oldParam.ValidValues));
             newParam.Value = selected;
             Parameters.Add(newParam);
             oldParam.ValidValues.Clear();
         }
         #endregion
         encoding.OperatorsChanged += Encoding_OperatorsChanged;
     }
 }
Пример #5
0
    private void AfterDeserialization() {
      // BackwardsCompatibility3.3
      #region Backwards compatible code, remove with 3.4
      if (!Parameters.ContainsKey("ReevaluateElites")) {
        Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true });
      }
#pragma warning disable 0618
      if (Parameters.ContainsKey("SimilarityCalculator") && Parameters["SimilarityCalculator"] is IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>) {
        var oldParameter = (IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"];
#pragma warning restore 0618
        Parameters.Remove(oldParameter);
        var newParameter = new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.", new ItemSet<ISolutionSimilarityCalculator>(oldParameter.ValidValues));
        var selectedSimilarityCalculator = newParameter.ValidValues.SingleOrDefault(x => x.GetType() == oldParameter.Value.GetType());
        newParameter.Value = selectedSimilarityCalculator;
        Parameters.Add(newParameter);
      }
      #endregion
      Initialize();
    }
Пример #6
0
    private void AfterDeserialization() {
      // BackwardsCompatibility3.3
      #region Backwards compatible code, remove with 3.4
      if (Parameters.ContainsKey("SimilarityCalculator") && Parameters["SimilarityCalculator"] is IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>) {
#pragma warning disable 0618
        var oldParameter = (IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"];
#pragma warning restore 0618
        Parameters.Remove(oldParameter);
        var newParameter = new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.", new ItemSet<ISolutionSimilarityCalculator>(oldParameter.ValidValues));
        var selectedSimilarityCalculator = newParameter.ValidValues.SingleOrDefault(x => x.GetType() == oldParameter.Value.GetType());
        newParameter.Value = selectedSimilarityCalculator;
        Parameters.Add(newParameter);
      }
      #endregion
      Initialize();
    }