Example #1
0
  private void backtrack(CPA cpa) throws InterruptedException {
    if (IA()) {
      Stop();
    } else {
      System.out.println(
          ID
              + "is running and AV is "
              + AgentView
              + " and cpa  is "
              + cpa
              + " from func backtrack");
      Assignment last = cpa.Last_Assignment();
      if (last != null) {
        cpa = cpa.shortest_inconsistent_partail_assignment(AgentView);
        System.out.println(
            ID
                + "is running and AV is "
                + AgentView
                + " and cpa  is "
                + cpa
                + " from func backtrack");
        int backto = last.getID();
        AgentView_consistent = false;
        initilize_domain();

        send(new Message("Backtrack_CPA", cpa), backto);
      } else {
        System.out.println("last message is null and got backtrack - SHOULDNT HAPPEN");
      }
    }
  }
Example #2
0
  private boolean updateAgentView(CPA cpa) {

    CPA shortest_inconsistent_partail_assignment =
        cpa.shortest_inconsistent_partail_assignment(AgentView);
    adjustAgentView(cpa);
    if (isEmptyDomain()) {
      AgentView = shortest_inconsistent_partail_assignment;
      return false;
    }
    return true;
  }
Example #3
0
  private void assignCPA(CPA cpa) throws Exception {

    if (is_assigned(cpa)) {
      if (isfull(cpa)) {
        report_solution(cpa);
        Stop();
      } else {

        cpa.increas_counter();
        send(new Message("CPA", cpa), next(cpa));
        System.out.println("######" + next(cpa));
        send(new Message("FC_CPA", cpa), other_unassigned_agents_excep(next(cpa), cpa));
        System.out.println("######" + next(cpa));
      }
    } else {

      AgentView = cpa.shortest_inconsistent_partail_assignment(AgentView);
      backtrack(AgentView);
    }
  }