コード例 #1
0
  public LinkedList<Entry> localSearch() {
    // Deep copy of a list
    this.neighbors_list = new LinkedList<Entry>();
    for (Entry e : this.solution_list) {
      this.neighbors_list.add(e);
    }

    int iteration = 0;

    while (iteration++ < this.max_iterations) {
      this.removeFromSolution();
      if (this.selectFromCandidates() != null) {
        // this.removeSelectedFromCandidates();
        this.removeSelectedFromNeighbors();
        System.out.println("ENTER");
      }
    }

    int cost = 0;
    for (Entry e : this.neighbors_list) {
      cost += e.getCost();
      System.out.println(e.toString());
    }
    System.out.println(cost);

    return (this.neighbors_list);
  }
コード例 #2
0
 public Entry selectFromSolution() {
   int pos = this.rand.nextInt(this.solution_list.size());
   Entry e = this.solution_list.get(pos);
   this.total_cost -= e.getCost();
   return e;
 }