コード例 #1
0
ファイル: Agent.java プロジェクト: bennylut/azapi-test
 /**
  * stop execution - returning the given assignment, will cause a TERMINATION message to be sent to
  * all other agents, if ans is null there is no solution
  *
  * @param ans
  */
 protected void finish(Assignment ans) {
   if (ans == null) {
     controller.reportNoSolution();
   } else {
     controller.assignAll(ans);
   }
   terminate();
 }
コード例 #2
0
ファイル: Agent.java プロジェクト: bennylut/azapi-test
 /**
  * if this method return null the message is rejected and should be dumped.
  *
  * @param currentMessage
  * @return
  */
 public final Message setCurrentMessage(Message currentMessage) {
   this.currentMessage = currentMessage;
   if (!controller.isControlling(currentMessage.getSender())
       && !SYS_TERMINATION_MESSAGE.equals(currentMessage.getName())) {
     messageCount[controller.pid()]++;
   }
   return beforeMessageProcessing(currentMessage);
 }
コード例 #3
0
ファイル: Agent.java プロジェクト: bennylut/azapi-test
 public final ContinuationMediator exec(Agent agent, String contextId) {
   try {
     return controller.nest(agent, contextId);
   } catch (ClassNotFoundException ex) {
     throw new RuntimeException(ex);
   }
 }
コード例 #4
0
ファイル: Agent.java プロジェクト: bennylut/azapi-test
  /**
   * @return the last submitted assignment will throw InvalideValueException if no assignment was
   *     submitted
   */
  protected Integer getAssignment() {
    Integer assignment = controller.getAssignment(id);
    if (assignment != null) {
      return assignment;
    }

    throw new InvalidValueException(
        "Agent called 'getSubmitedCurrentAssignment' before he ever called 'submitCurrentAssignment'");
  }
コード例 #5
0
ファイル: Agent.java プロジェクト: bennylut/azapi-test
 /**
  * Note: the concept 'system time' only exists in synchronized execution
  *
  * @return the number of ticks passed since the algorithm start (first tick is 0), you can read
  *     about the definition of tick in agent zero manual
  */
 public long getSystemTimeInTicks() {
   return controller.getTickNumber();
 }
コード例 #6
0
ファイル: Agent.java プロジェクト: bennylut/azapi-test
 /** remove the submitted current assignment */
 protected void unassign() {
   controller.unassign(id);
 }
コード例 #7
0
ファイル: Agent.java プロジェクト: bennylut/azapi-test
 /**
  * the agent can submit its assignment so that when the algorithm is finish running (happened when
  * all agents call finish) this will be the assignment to be accumulated - if you want to
  * re-assign a new value you don't have to call unSubmitCurrentAssignment, you can just call this
  * function again with the new value
  *
  * @param currentAssignment the assignment to submit
  */
 protected void assign(int currentAssignment) {
   controller.assign(getId(), currentAssignment);
 }
コード例 #8
0
ファイル: Agent.java プロジェクト: bennylut/azapi-test
 /**
  * log something inside this agent log
  *
  * @param what
  */
 protected void log(String what) {
   controller.log(id, what);
 }