~spidernet/PermutationFlowShopScheduling

0960cd75be7aea5e6336131ee0998846dca5109f — Alessio Chiapperini 1 year, 9 months ago 99ba9f9
[LocalSearch] Added comments to FP_State and FP_Basics
2 files changed, 15 insertions(+), 3 deletions(-)

M LocalSearch/include/FP_Basics.hh
M LocalSearch/src/FP_Basics.cc
M LocalSearch/include/FP_Basics.hh => LocalSearch/include/FP_Basics.hh +2 -1
@@ 13,7 13,6 @@ class FP_State {
  FP_State& operator=(const FP_State& s);
  size_t operator[](unsigned i) const { return schedule[i]; }
  size_t& operator[](unsigned i) { return schedule[i]; }
  /*void reset();*/
  void ComputeTimes(size_t job_index = 0);
  size_t getEndTime(size_t j, size_t m) const { return end_times[j][m]; }
  size_t getScheduleIndex(size_t job) const;


@@ 25,6 24,7 @@ class FP_State {
  vector<vector<size_t>> end_times;
};

// Swap job i and job j.
class SwapJobs {
  friend bool operator==(const SwapJobs& m1, const SwapJobs& m2);
  friend bool operator!=(const SwapJobs& m1, const SwapJobs& m2);


@@ 37,6 37,7 @@ class SwapJobs {
  size_t j1, j2;
};

// Move job from index p1 to index p2.
class MoveJob {
  friend bool operator==(const MoveJob& m1, const MoveJob& m2);
  friend bool operator!=(const MoveJob& m1, const MoveJob& m2);

M LocalSearch/src/FP_Basics.cc => LocalSearch/src/FP_Basics.cc +13 -2
@@ 6,6 6,8 @@ FP_State::FP_State(const FP_Input& my_in) : in(my_in) {
  schedule.resize(my_in.getJobs());
  start_times.resize(in.getJobs(), vector<size_t>(in.getMachines()));
  end_times.resize(in.getJobs(), vector<size_t>(in.getMachines()));

  // Default state = [0,1,2,...,jobs-1]
  for (size_t i = 0; i < my_in.getJobs(); i++) {
    schedule[i] = i;
  }


@@ 33,6 35,10 @@ ostream& operator<<(ostream& os, const FP_State& st) {
  return os;
}

/*!
 * @brief Computes start and end time for each job and each machine starting from `job_index`
 * @param[in] job_index     The index of the job from which to start computing the start and end times.
 */
void FP_State::ComputeTimes(size_t job_index) {
  size_t j;
  for (size_t m = 0; m < in.getMachines(); ++m) {


@@ 52,9 58,14 @@ void FP_State::ComputeTimes(size_t job_index) {
  }
}

/*!
 * @brief Returns the index of the job passed as input in the schedule.
 * @param[in] job   The job number for which we want to get its index.
 * @return The index of the provided job inside the schedule.
 */
size_t FP_State::getScheduleIndex(size_t job) const {
  long d = distance(schedule.begin(), find(schedule.begin(), schedule.end(), job));
  if (d >= 0) return static_cast<size_t >(d);
  if (d >= 0) return static_cast<size_t>(d);
  else throw logic_error("Negative vector index");
}



@@ 126,4 137,4 @@ istream& operator>>(istream& is, MoveJob& mv) {
ostream& operator<<(ostream& os, const MoveJob& mv) {
  os << "(" << mv.p1 << "," << mv.p2 << ")";
  return os;
}
\ No newline at end of file
}