Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/05/17 13:35:20 (6 years ago)
Author:
abeham
Message:

#2747: Implemeted hard-coded genetic algorithm for faster evaluation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CFSAP/HeuristicLab.Problems.Scheduling.CFSAP/3.3/CFSAP.cs

    r15472 r15493  
    108108      var order = individual.Permutation("sequence");
    109109      var assignment = individual.BinaryVector("assignment");
    110       int T = EvaluateAssignement(order, assignment.Select(x => x ? 1 : 0).ToArray(),
    111         ProcessingTimesParameter.Value, SetupTimesParameter.Value);
    112       return T;
     110      return Evaluate(order, assignment);
     111    }
     112
     113    public int Evaluate(Permutation order, BinaryVector assignment) {
     114      return EvaluateAssignement(order, assignment, ProcessingTimes, SetupTimes);
    113115    }
    114116
     
    130132          int operation = order[i];
    131133          if (assignment[operation] == machine) {
     134            if (first == -1)
     135              first = operation;
     136            else
     137              T += setupTimes[machine][last, operation];
     138            last = operation;
     139          }
     140        }
     141        if (last != -1 && first != -1)
     142          T += setupTimes[machine][last, first];
     143      }
     144
     145      return T;
     146    }
     147
     148    //Function to evaluate individual with the specified assignment
     149    public static int EvaluateAssignement(Permutation order, BinaryVector assignment, IntMatrix processingTimes, ItemList<IntMatrix> setupTimes) {
     150      if (processingTimes.Rows != 2) throw new ArgumentException("Method can only be used when there are two machines.", "assignment");
     151      var N = order.Length;
     152      int T = 0;
     153
     154      for (int i = 0; i < N; i++) {
     155        int operation = order[i];
     156        int machine = assignment[operation] ? 1 : 0;
     157        T += processingTimes[machine, operation];
     158      }
     159
     160      for (int machine = 0; machine < 2; machine++) {
     161        int first = -1;
     162        int last = -1;
     163        for (int i = 0; i < N; i++) {
     164          int operation = order[i];
     165          if ((assignment[operation] ? 1 : 0) == machine) {
    132166            if (first == -1)
    133167              first = operation;
Note: See TracChangeset for help on using the changeset viewer.