Package it.unito.di.logic.expression

Examples of it.unito.di.logic.expression.CompositeExpression


     proposal.setPerformative(ACLMessage.PROPOSE);
    send(proposal);
   
    try {
      assertFact(new Fact("propose", participant, prop));
      createCommitment(new Commitment(participant, initiator, new Fact("accept"), new CompositeExpression(
          LogicalOperatorType.OR, new Fact("done"), new Fact("failure"))));
      //**** DEBUG: CAMBIO STATO DI VITA A COMMITMENT GIUSTO, SARA' IL SOCIAL STATE CHE DOVRA' GESTIRLO
      for (Commitment com : interactionState.retrieveCommitmentsByCreditorRoleId(participant)) {
        if (com.getAntecedent().equals(new Fact("propose")) && com.getLifeCycleStatus().equals(LifeCycleState.CONDITIONAL)) {
          Commitment cToAdd = new Commitment(com.getDebtor(), com.getCreditor(), new Fact("true"), com.getConsequent(), LifeCycleState.DETACHED)
          interactionState.removeCommitment(com);
          logger.debug("Commitment da rimuovere: "+com);
          createCommitment(cToAdd)
          actualProposals++;           
        }
      }
      if (actualProposals == numberMaxProposals) {
        acceptingProposals = false;
        RoleId groupParticipant = new RoleId(PARTICIPANT_ROLE, RoleId.GROUP_ROLE);
        createCommitment(new Commitment(initiator, groupParticipant, new CompositeExpression(
            LogicalOperatorType.OR, new Fact("accept"), new Fact("reject"))));
//        defineObsProperty("cc", initiator.getCanonicalName(), "GroupParticipant",
//            "true", "(accept OR reject)", "DETACHED");
       
      }
View Full Code Here


    refusal.setRoleReceiver(initiator);
    refusal.setPerformative(ACLMessage.REFUSE);
    send(refusal);
   
    try {
      releaseCommitment(new Commitment(initiator, participant, "propose", new CompositeExpression(
          LogicalOperatorType.OR, new Fact("accept"), new Fact("reject"))));
      assertFact(new Fact("refuse", participant));
      logger.trace("OPERATION PERFORMED: REFUSE by "+participant);
    } catch (MissingOperandException e) {
      // TODO Auto-generated catch block
View Full Code Here

    send(done);
   
    try {
      ArrayList<Commitment> arrComm = new ArrayList<Commitment>();
      for (Commitment com : interactionState.retrieveCommitmentsByDebtorRoleId(participant)) {
        if (com.getConsequent().equals(new CompositeExpression(LogicalOperatorType.OR, new Fact("done"), new Fact("failure")))) {
          arrComm.add(com);
        }
      }
      for (Commitment com :arrComm) {
        if (com.getConsequent().equals(new CompositeExpression(LogicalOperatorType.OR, new Fact("done"), new Fact("failure")))) {
          Commitment cToAdd = new Commitment(com.getDebtor(), com.getCreditor(), com.getAntecedent(), com.getConsequent(), LifeCycleState.DISCHARGED)
          interactionState.removeCommitment(com);
          logger.debug("Commitment da rimuovere: "+com);
          createCommitment(cToAdd);       
        }
View Full Code Here

    failure.setPerformative(ACLMessage.FAILURE);
    send(failure);
    try {
      ArrayList<Commitment> arrComm = new ArrayList<Commitment>();
      for (Commitment com : interactionState.retrieveCommitmentsByDebtorRoleId(participant)) {
        if (com.getConsequent().equals(new CompositeExpression(LogicalOperatorType.OR, new Fact("done"), new Fact("failure")))) {
          arrComm.add(com);
        }
      }
      for (Commitment com :arrComm) {
        if (com.getConsequent().equals(new CompositeExpression(LogicalOperatorType.OR, new Fact("done"), new Fact("failure")))) {
          Commitment cToAdd = new Commitment(com.getDebtor(), com.getCreditor(), com.getAntecedent(), com.getConsequent(), LifeCycleState.DISCHARGED)
          interactionState.removeCommitment(com);
          logger.debug("Commitment da rimuovere: "+com);
          createCommitment(cToAdd);       
        }
View Full Code Here

    logger.debug("Test retrieving commitments by status...");
    logger.debug(state.retrieveCommitmentsByLifecycleStatus(LifeCycleState.CONDITIONAL));
   
    logger.debug("Test cancel operation.");
   
    CompositeExpression ce, ce1;
    try {
      ce = new CompositeExpression(LogicalOperatorType.OR, new Fact("done"), new Fact("failure"));
      ce1 = new CompositeExpression(LogicalOperatorType.OR, new Fact("done"), new Fact("failure"));
      logger.debug("Adding...");
      logger.debug(ce);
      state.assertFact(ce);
      logger.debug(state);
      logger.debug("Testing equality: "+ce.equals(ce1));
     
    } catch (MissingOperandException | WrongOperandsNumberException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    } catch (LogicalExpressionAlreadyAddedException e) {
View Full Code Here

public class ParticipantRequirements extends Type {
 
  public ParticipantRequirements() throws MissingOperandException, WrongOperandsNumberException {     
    super(new Commitment[]{
        new Commitment(CNPArtifact.PARTICIPANT_ROLE, CNPArtifact.INITIATOR_ROLE, "accept", new CompositeExpression(
              LogicalOperatorType.OR, new Fact("done"), new Fact("failure")))
        });
   
  }
View Full Code Here

  public void cfp(String task) {
    RoleId initiator = getRoleIdByPlayerName(getOpUserName());
    this.defineObsProperty("task", task, initiator.getCanonicalName());
    RoleId dest = new RoleId(PARTICIPANT_ROLE);
     try {     
      createAllCommitments(new Commitment(initiator, dest, "propose", new CompositeExpression(
          LogicalOperatorType.OR, new Fact("accept"), new Fact("reject"))));
      assertFact(new Fact("cfp", initiator, task));
      logger.trace("OPERATION PERFORMED: CFP by "+initiator.getPlayerAgentId().getGlobalId());
    } catch (MissingOperandException e) {
      // TODO Auto-generated catch block
View Full Code Here

    p.setRoleId(participant);
    // VERSIONE CON SIGNAL PARTICOLARE
    // signal(initiator.getPlayerAgentId(), "proposal", p.getProposalContent(), p.getCost(), participant.getCanonicalName());
    defineObsProperty("proposal", p.getProposalContent(), p.getCost(), participant.getCanonicalName());
     try {     
      createCommitment(new Commitment(participant, initiator, "accept", new CompositeExpression(
          LogicalOperatorType.OR, new Fact("done"), new Fact("failure"))));
      assertFact(new Fact("propose", participant, prop));
     
      //**** DEBUG: CAMBIO STATO DI VITA A COMMITMENT GIUSTO, SARA' IL SOCIAL STATE CHE DOVRA' GESTIRLO
      for (Commitment com : interactionState.retrieveCommitmentsByCreditorRoleId(participant)) {
        if (com.getAntecedent().equals(new Fact("propose")) && com.getLifeCycleStatus().equals(LifeCycleState.CONDITIONAL)) {
            removeObsPropertyByTemplate("cc", com.getDebtor().getCanonicalName(), com.getCreditor().getCanonicalName(),
                com.getAntecedent().toString(), com.getConsequent().toString(), com.getLifeCycleStatus().toString());
            com.setStatus(LifeCycleState.DETACHED);
            com.setAntecedent(new Fact("true"));
            actualProposals++;
            defineObsProperty("cc", com.getDebtor().getCanonicalName(), com.getCreditor().getCanonicalName(),
                com.getAntecedent().toString(), com.getConsequent().toString(), com.getLifeCycleStatus().toString());
           
        }
      }
      if (actualProposals == numberMaxProposals) {
        RoleId groupParticipant = new RoleId(PARTICIPANT_ROLE);
        createCommitment(new Commitment(initiator, groupParticipant, new CompositeExpression(
            LogicalOperatorType.OR, new Fact("accept"), new Fact("reject"))));
//        defineObsProperty("cc", initiator.getCanonicalName(), "GroupParticipant",
//            "true", "(accept OR reject)", "DETACHED");
       
      }
View Full Code Here

    refusal.setRoleReceiver(initiator);
    refusal.setPerformative(ACLMessage.REFUSE);
    send(refusal);
   
    try {
      releaseCommitment(new Commitment(initiator, participant, "propose", new CompositeExpression(
          LogicalOperatorType.OR, new Fact("accept"), new Fact("reject"))));
      assertFact(new Fact("refuse", participant));
      logger.trace("OPERATION PERFORMED: REFUSE by "+participant);
    } catch (MissingOperandException e) {
      // TODO Auto-generated catch block
View Full Code Here

    defineObsProperty("done", result);
    long now = new Date().getTime();
    log("TIME ELAPSED: "+((now-millis)/1000));
    try {
      for (Commitment com : interactionState.retrieveAllCommitments()) {
        if (com.getConsequent().equals(new CompositeExpression(LogicalOperatorType.OR, new Fact("done"), new Fact("failure")))
                && com.getDebtor().equals(rolePart)) {
            removeObsPropertyByTemplate("cc", com.getDebtor().getCanonicalName(), com.getCreditor().getCanonicalName(),
                com.getAntecedent().toString(), com.getConsequent().toString(), com.getLifeCycleStatus().toString());
            com.setStatus(LifeCycleState.DISCHARGED);
            defineObsProperty("cc", com.getDebtor().getCanonicalName(), com.getCreditor().getCanonicalName(),
View Full Code Here

TOP

Related Classes of it.unito.di.logic.expression.CompositeExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.