Package ora4mas.nopl

Class SchemeBoard

  • All Implemented Interfaces:
    ToXML, npl.DynamicFactsProvider
    Direct Known Subclasses:
    LightSchemeBoard

    public class SchemeBoard
    extends OrgArt
    Artifact to manage a scheme instance.

    Operations (see details in the methods list below):
    • commitMission
    • leaveMission
    • goalAchieved
    • setArgumentValue
    • resetGoal
    • destroy
    Observable properties:
    • commitment(ag,mission,sch): agent ag is committed to the mission in the scheme (we have as many obs prop as commitments).
      e.g. commitment(bob,mission1,s1)
    • groups: a list of groups responsible for the scheme.
      e.g. groups([g1])
    • goalState(schId, goal, list of committed agents, list of agents that performed the goal, state); where states are: waiting, enabled, satisfied).
      e.g. goalState(s1,g5,[alice,bob],[alice],satisfied)
    • specification: the specification of the scheme in the OS (a prolog like representation).
    • obligation(ag,reason,goal,deadline): current active obligations.
      e.g. obligation(bob,ngoal(s1,mission1,g5),done(s1,bid,bob),1475417322254)
    • permission(ag,reason,goal,deadline): current active permission.
    • goalArgument(schemeId, goalId, argId, value): value of goals' arguments, defined by the operation setArgumentValue
      e.g. goalArgument(sch1, winner, "W", "Bob")
    Signals (obligation o has the form: obligation(to whom, maintenance condition, what, deadline)):
    • oblCreated(o): the obligation o is created.
    • oblFulfilled(o): the obligation o is fulfilled
    • oblUnfulfilled(o): the obligation o is unfulfilled (e.g. by timeout).
    • oblInactive(o): the obligation o is inactive (e.g. its maintenance condition does not hold anymore).
      e.g. o = obligation(Ag,_,done(Sch,bid,Ag), TTF) if the bid is a performance goal and o = obligation(Ag,_,satisfied(Sch,bid), TTF) if the bid is an achievement goal.
    • normFailure(f): the failure f has happened (e.g. due some regimentation).
      e.g. f = fail(mission_permission(Ag,M,Sch)). The f comes from the normative program.
    Author:
    Jomi
    See Also:
    Scheme
    • Field Detail

      • obsPropCommitment

        public static final java.lang.String obsPropCommitment
        See Also:
        Constant Field Values
      • piGoalState

        public static final jason.asSyntax.PredicateIndicator piGoalState
      • schBoards

        protected static java.util.Collection<SchemeBoard> schBoards
      • logger

        protected java.util.logging.Logger logger
      • goalStObsProps

        private java.util.List<cartago.ObsProperty> goalStObsProps
      • aWaiting

        protected static final jason.asSyntax.Atom aWaiting
      • aEnabled

        protected static final jason.asSyntax.Atom aEnabled
      • aSatisfied

        protected static final jason.asSyntax.Atom aSatisfied
    • Constructor Detail

      • SchemeBoard

        public SchemeBoard()
    • Method Detail

      • getSchemeBoards

        public static java.util.Collection<SchemeBoard> getSchemeBoards()
      • getLogger

        protected java.util.logging.Logger getLogger()
        Overrides:
        getLogger in class OrgArt
      • getSchState

        public Scheme getSchState()
      • getSpec

        public Scheme getSpec()
      • init

        public void init​(java.lang.String osFile,
                         java.lang.String schType)
                  throws npl.parser.ParseException,
                         MoiseException
        Initialises the scheme artifact
        Parameters:
        osFile - the organisation specification file (path and file name)
        schType - the type of the scheme (as defined in the OS)
        Throws:
        npl.parser.ParseException - if the OS file is not correct
        MoiseException - if schType was not specified
      • reorganise

        protected void reorganise()
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • debug

        public void debug​(java.lang.String kind)
      • destroy

        public void destroy()
        The agent executing this operation tries to delete the scheme board artifact
        Overrides:
        destroy in class OrgArt
      • agKilled

        public void agKilled​(java.lang.String agName)
        Overrides:
        agKilled in class OrgArt
      • commitMission

        public void commitMission​(java.lang.String mission)
                           throws cartago.CartagoException
        The agent executing this operation tries to commit to a mission in the scheme.

        Verifications:

        • mission max cardinality
        • mission permission (if the agent plays a role that permits it to commit to the mission)
        Parameters:
        mission - the mission being committed to
        Throws:
        npl.NormativeFailureException - the failure produced if the adoption breaks some regimentation
        cartago.CartagoException - some cartago problem
      • commitMission

        protected void commitMission​(java.lang.String ag,
                                     java.lang.String mission)
                              throws cartago.CartagoException
        Throws:
        cartago.CartagoException
      • leaveMission

        public void leaveMission​(java.lang.String mission)
                          throws cartago.CartagoException,
                                 MoiseException
        The agent executing this operation tries to leave/remove its mission in the scheme

        Verifications:

        • the agent must be committed to the mission
        • the mission's goals have to be satisfied (otherwise the agent is obliged to commit again to the mission)
        Parameters:
        mission - the mission being removed
        Throws:
        npl.NormativeFailureException - the failure produced if the remove breaks some regimentation
        cartago.CartagoException - some cartago problem
        MoiseException - some moise inconsistency (the agent is not committed to the mission)
      • goalAchieved

        public void goalAchieved​(java.lang.String goal)
                          throws cartago.CartagoException
        The agent executing this operation set the goal as performed by it.

        Verifications:

        • the agent must be committed to the goal
        • the goal has to be enabled
        Throws:
        cartago.CartagoException
      • goalDone

        protected void goalDone​(java.lang.String agent,
                                java.lang.String goal)
                         throws cartago.CartagoException
        Throws:
        cartago.CartagoException
      • setArgumentValue

        public void setArgumentValue​(java.lang.String goal,
                                     java.lang.String var,
                                     java.lang.Object value)
                              throws cartago.CartagoException
        The agent executing this operation sets a value for a goal argument.
        Parameters:
        goal - The goal to which the value should be added
        var - name of the variable to which the value is modified
        value - value set to the variable of the goal
        Throws:
        cartago.CartagoException
      • resetGoal

        public void resetGoal​(java.lang.String goal)
                       throws cartago.CartagoException
        The agent executing this operation reset some goal. It becomes not achieved, also goals that depends on it or sub-goals are set as unachieved
        Parameters:
        goal - The goal to be reset
        Throws:
        cartago.CartagoException
      • getState

        public void getState​(cartago.OpFeedbackParam<Scheme> s)
      • mergeState

        public void mergeState​(java.lang.Object s)
      • admCommand

        public void admCommand​(java.lang.String cmd)
                        throws cartago.CartagoException,
                               jason.asSyntax.parser.ParseException,
                               jason.NoValueException,
                               MoiseException,
                               npl.parser.ParseException
        Commands that the owner of the scheme can perform.
        Parameters:
        cmd - , possible values (as strings): commitMission(,), goalDone(,) -- for performance goals --, goalSatisfied() -- for achievement goals -- setCardinality(,,,) [element type=mission]
        Throws:
        cartago.CartagoException
        jason.asSyntax.parser.ParseException
        MoiseException
        jason.NoValueException
        npl.parser.ParseException
      • addMission

        public void addMission​(java.lang.String missionId)
                        throws MoiseException,
                               npl.parser.ParseException
        Throws:
        MoiseException
        npl.parser.ParseException
      • setCardinality

        public void setCardinality​(java.lang.String element,
                                   java.lang.String id,
                                   int min,
                                   int max)
                            throws MoiseException,
                                   npl.parser.ParseException
        Throws:
        MoiseException
        npl.parser.ParseException
      • enableSatisfied

        protected void enableSatisfied​(java.lang.String goal)
      • interactionCommand

        public void interactionCommand​(java.lang.String cmd)
                                throws cartago.CartagoException,
                                       jason.asSyntax.parser.ParseException
        Throws:
        cartago.CartagoException
        jason.asSyntax.parser.ParseException
      • updateRolePlayers

        protected void updateRolePlayers​(java.lang.String grId,
                                         java.util.Collection<Player> rp)
                                  throws npl.NormativeFailureException,
                                         cartago.CartagoException
        Throws:
        npl.NormativeFailureException
        cartago.CartagoException
      • removeResponsibleGroup

        void removeResponsibleGroup​(java.lang.String grId)
                             throws cartago.CartagoException
        Throws:
        cartago.CartagoException
      • updateGoalArgsObsProp

        protected void updateGoalArgsObsProp()
      • updateGoalStateObsProp

        protected void updateGoalStateObsProp()
      • isObsPropEqualsGoal

        protected boolean isObsPropEqualsGoal​(jason.asSyntax.Literal g,
                                              cartago.ObsProperty op)
      • getGoalStates

        java.util.List<jason.asSyntax.Literal> getGoalStates()
      • getNPLSrc

        public java.lang.String getNPLSrc()
        Overrides:
        getNPLSrc in class OrgArt
      • getStyleSheetName

        protected java.lang.String getStyleSheetName()
        Specified by:
        getStyleSheetName in class OrgArt
      • isWellFormed

        public boolean isWellFormed()
      • getAsDOM

        public org.w3c.dom.Element getAsDOM​(org.w3c.dom.Document document)
      • addMissionsInDot

        protected boolean addMissionsInDot()
      • getAsDot

        public java.lang.String getAsDot()
        Overrides:
        getAsDot in class OrgArt