Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/17/20 16:30:40 (5 years ago)
Author:
kyang
Message:

#3055: Fixed the bug of "no reference point" on real-world test problems

Location:
branches/3055_SMSEMOA/HeuristicLab.Algorithms.SMSEMOA/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3055_SMSEMOA/HeuristicLab.Algorithms.SMSEMOA/3.4/SMSEMOAAlgorithm.cs

    r17425 r17440  
    103103      var analyzer = Analyzer;
    104104      var rand = RandomParameter.Value;
    105       int lambda = 1;            // the size of offspring
     105      //int lambda = 1;            // the size of offspring
     106      var lambda = Lambda.Value;
    106107      //int indexOffspring = 0;    // the index of offspring to be generated
    107108
  • branches/3055_SMSEMOA/HeuristicLab.Algorithms.SMSEMOA/3.4/SMSEMOAlgorithmBase.cs

    r17425 r17440  
    101101    private DoubleArray ReferencePoint {
    102102      get {
    103         var problem = (MultiObjectiveTestFunctionProblem)Problem;
    104         return problem.ReferencePoint;
     103        if (Problem is MultiObjectiveTestFunctionProblem) {
     104          var problem = (MultiObjectiveTestFunctionProblem)Problem;
     105          return problem.ReferencePoint;
     106        }
     107        else {
     108        return null;
     109        }
    105110      }
    106111    }
     
    250255
    251256    #region constructors
    252     public SMSEMOAAlgorithmBase() { 
     257    public SMSEMOAAlgorithmBase() {
    253258      // Add or define or specify the parameters that may be use in SMS-EMOA.   
    254259      // ***("Name", "Description", "Value")
     
    480485        var lastLayer = pf2.Last();
    481486
    482         try { // TODO: This can be use for dynamic reference point strategy later. Kaifeng , 02/2020
    483           // smetric = Hypervolume.Calculate(lastLayer.Select(x => x.Item2), Enumerable.Repeat(11d, NadirPoint.Length).ToArray(), maximization);
    484           smetric = Hypervolume.Calculate(lastLayer.Select(x => x.Item2), ReferencePoint.ToArray(), maximization);
    485         }
    486         catch {
    487           smetric = int.MinValue;
    488         }
    489 
    490         var indices = Enumerable.Range(0, lastLayer.Count()).ToList();
    491 
    492         for (int ii = 0; ii < lastLayer.Count(); ++ii) {
     487        // TODO: This can be use for dynamic reference point strategy later. Kaifeng , 02/2020
     488        // smetric = Hypervolume.Calculate(lastLayer.Select(x => x.Item2), Enumerable.Repeat(11d, NadirPoint.Length).ToArray(), maximization);
     489
     490
     491        var reference = Enumerable.Repeat(double.MaxValue, maximization.Length).ToArray();
     492        if (ReferencePoint is null) {     // KF, 20200217 -- fix no reference point on real-world applications. If No reference points in Algorithms, use 1.1 \times max objective values as the reference point
     493          for (int i = 0; i < reference.Length; i++) {
     494            reference[i] = 1.1 * reference[i];
     495            if (reference[i] > 10000) {
     496              reference[i] = 9999;          // set a upper bound for the reference point
     497            }
     498          }
     499        }
     500        else {
     501          reference = ReferencePoint.ToArray();
     502        }
     503        //var reference = ReferencePoint.ToArray();
     504        var nondominated = NonDominatedSelect.GetDominatingVectors(lastLayer.Select(x => x.Item2), reference, maximization, false);
     505        smetric = nondominated.Any() ? Hypervolume.Calculate(nondominated, reference, maximization) : int.MinValue;
     506
     507        for (int ii = 0; ii < lastLayer.Count; ++ii) {
    493508          try { // TODO: This can be use for dynamic reference point strategy later. Kaifeng , 02/2020
    494509            // tempHV = Hypervolume.Calculate(indices.Where(idx => idx != ii).Select(idx => lastLayer[idx].Item2), Enumerable.Repeat(11d, NadirPoint.Length).ToArray(), maximization);
    495             tempHV = Hypervolume.Calculate(indices.Where(idx => idx != ii).Select(idx => lastLayer[idx].Item2), ReferencePoint.ToArray(), maximization);
     510            tempHV = Hypervolume.Calculate(Enumerable.Range(0, lastLayer.Count).Where(idx => idx != ii).Select(idx => lastLayer[idx].Item2), reference, maximization);
    496511          }
    497512          catch {
     
    537552      //               True:  maximization problem
    538553      //               False: minimization problem
    539       hypervolumes[0, 0] = Hypervolume.Calculate(pf.Select(x => x.Item2), Enumerable.Repeat(11d, NadirPoint.Length).ToArray(), maximization);
     554      var reference = Enumerable.Repeat(double.MaxValue, maximization.Length).ToArray();
     555      if (ReferencePoint is null) {     // KF, 20200217 -- fix no reference point on real-world applications. If No reference points in Algorithms, use 1.1 \times max objective values as the reference point
     556        for (int i = 0; i < reference.Length; i++) {
     557          reference[i] = 1.1 * reference[i];
     558          if (reference[i] > 10000) {
     559            reference[i] = 9999;          // set a upper bound for the reference point
     560          }
     561        }
     562      }
     563      else {
     564        reference = ReferencePoint.ToArray();
     565      }
     566      //var reference = ReferencePoint.ToArray() ?? Enumerable.Repeat(double.MaxValue, maximization.Length).ToArray();
     567      //var reference = ReferencePoint.ToArray();
     568      var nondominated = NonDominatedSelect.GetDominatingVectors(pf.Select(x => x.Item2), reference, maximization, false);
     569      hypervolumes[0, 0] = nondominated.Any() ? Hypervolume.Calculate(nondominated, reference, maximization) : int.MinValue;
     570
     571      //hypervolumes[0, 0] = Hypervolume.Calculate(pf.Select(x => x.Item2), reference, maximization);
    540572      hypervolumes[0, 1] = pf.Count;
    541573      Console.WriteLine("Current HV is", hypervolumes[0, 0]);
Note: See TracChangeset for help on using the changeset viewer.