Example #1
0
  private boolean is_assigned(CPA cpa) throws Exception {
    boolean assignmets_constraied = false;
    int k = -1;
    for (int i = 0; i < Domain.length; i++) {
      k++;
      k = find_next_possible_assignment(k);
      if (k == -1) {
        emptyDomain();
        return false;
      }
      Assignment assignment = new Assignment(ID, k);
      for (int j = 0; j < cpa.length() && !assignmets_constraied; j++) {
        if (constrained(assignment, cpa.getAssignment(j))) {
          assignmets_constraied = true;
        }
      }
      if (!assignmets_constraied) {
        Domain[k] = 0;
        cpa.add_assignment(assignment);

        AgentView = cpa;

        return true;
      }
      assignmets_constraied = false;
    }
    return false;
  }
Example #2
0
  private int[] other_unassigned_agents_excep(
      int k,
      CPA
          cpa) { // returns an array. array[i]=1 if a message needs to be sent to i  and 0
                 // otherwise.
    int[] unassigned_agents = new int[num_of_agents];
    for (int i = 0; i < unassigned_agents.length; i++) {
      unassigned_agents[i] = 1;
    }
    unassigned_agents[k] = 0;
    for (int i = 0; i < cpa.length() && cpa.getAssignment(i) != null; i++) {
      unassigned_agents[cpa.getID(i)] = 0;
    }

    return unassigned_agents;
  }
Example #3
0
 private void setDomain(CPA cpa) {
   for (int i = 0; i < cpa.length(); i++) {
     Assignment ass = cpa.getAssignment(i);
     if (ass != null) {
       int agentID = ass.getID();
       int assValue = ass.getValue();
       if (constrained_agents(agentID, this.ID)) {
         int[][] values = constraints[agentID][this.ID];
         System.out.println("#### the value is    " + values[4][4]);
         for (int j = 0; j < Domain.length; j++) {
           if (values[j][assValue] == 1) { // values are constrained
             Domain[j] = 0;
           }
         }
       }
     } else {
       break;
     }
   }
 }
Example #4
0
 private void setAgentView(CPA cpa) {
   for (int i = 0; i < AgentView.length(); i++) {
     AgentView.setAssignment(cpa.getAssignment(i), i);
   }
 }