All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.agentsoz.vaccination.jack.ConsiderVaccination Maven / Gradle / Ivy

/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  This code is generated by JAC version 5.6 by
  Agent Oriented Software. http://www.agent-software.com.au

    DO NOT ALTER THIS CODE AND DO NOT REMOVE THIS COMMENT
 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
package io.github.agentsoz.vaccination.jack;

/*
 * #%L
 * BDI-ABM Integration Package
 * %%
 * Copyright (C) 2014 - 2017 by its authors. See AUTHORS file.
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */
import aos.jack.jak.plan.Plan;
import aos.jack.jak.plan.PlanFSM;
import aos.jack.jak.plan.ExMap;
import aos.jack.jak.agent.NameSpace;
import aos.jack.jak.event.Event;
import aos.jack.jak.task.Task;
import aos.jack.jak.core.Generator;
import aos.jack.jak.logic.Signature;
import io.github.agentsoz.vaccination.Log;
import java.lang.Object;
import aos.jack.jak.cursor.Cursor;
import aos.jack.jak.fsm.FSM;
import io.github.agentsoz.vaccination.Global;
import aos.jack.jak.core.Jak;

public class ConsiderVaccination extends aos.jack.jak.plan.Plan {
    public io.github.agentsoz.vaccination.jack.DoConsiderVaccination event;
    public io.github.agentsoz.vaccination.jack.DoActOnVaccinationDecision act;
    private static aos.jack.jak.plan.ExMap[] __exMap_fail;
    private static java.lang.String[] __tt__fail = {
            "io/github/agentsoz/vaccination/jack/ConsiderVaccination.plan",
            "fail",
            "58",
            "57"};
    private static aos.jack.jak.plan.ExMap[] __exMap_pass;
    private static java.lang.String[] __tt__pass = {
            "io/github/agentsoz/vaccination/jack/ConsiderVaccination.plan",
            "pass",
            "62",
            "61"};
    private static aos.jack.jak.plan.ExMap[] __exMap_body;
    private static java.lang.String[] __tt__body = {
            "io/github/agentsoz/vaccination/jack/ConsiderVaccination.plan",
            "body",
            "24",
            "27",
            "30",
            "33",
            "22"};
    private final static java.lang.String[] __planVariableNames = {
            "event",
            "act"};
    private final static java.lang.String[] __planVariableTypes = {
            "DoConsiderVaccination",
            "io.github.agentsoz.vaccination.jack.DoActOnVaccinationDecision"};
    private final static java.lang.String[] __reasoningMethods = {
            "body",
            "fail",
            "pass"};
    private final static java.lang.String[] __fsmVariableNames_body = {
            "agent",
            "decision"};
    private final static java.lang.String[] __fsmTypes_body = {
            "Householder",
            "String"};
    private final static java.lang.String[] __fsmLocalNames_body = {
            "__local__5_0",
            "__local__5_1"};
    static boolean relevant(io.github.agentsoz.vaccination.jack.DoConsiderVaccination ev)
    {
        return true;
    }
    
    /**
	 * Make a random decision about vaccination.
	 */

    private java.lang.String randomDecision()
    {
        io.github.agentsoz.vaccination.jack.Householder agent = (io.github.agentsoz.vaccination.jack.Householder) getAgent();
        java.lang.String decision = io.github.agentsoz.vaccination.Global.UNDECIDED;
        switch (io.github.agentsoz.vaccination.Global.getRandomInstance().nextInt(2)) {
            case 0: 
            {
                decision = io.github.agentsoz.vaccination.Global.DECIDED_TO_REJECT_VACCINATION;
                break;
            }
            case 1: 
            {
                decision = io.github.agentsoz.vaccination.Global.DECIDED_TO_VACCINATE;
                break;
            }
            case 2: 
            {
                decision = io.github.agentsoz.vaccination.Global.DECIDED_TO_DELAY_VACCINATION;
                break;
            }
        }
        return decision;
    }
    
    public ConsiderVaccination()
    {
    }
    
    private ConsiderVaccination(aos.jack.jak.task.Task __t, io.github.agentsoz.vaccination.jack.ConsiderVaccination __env)
    {
        __agent = __env.__agent;
        __ns = __env.__ns;
        __planTask = __t;
        __logic = __t.logic;
        event = __env.event;
        act = __env.act;
    }
    
    public boolean init_sentinel(aos.jack.jak.agent.NameSpace __a)
    {
        event = (io.github.agentsoz.vaccination.jack.DoConsiderVaccination) __a.findEvent("io.github.agentsoz.vaccination.jack.DoConsiderVaccination");
        if (event == null) {
            warning("DoConsiderVaccination event: is not found in the capability/agent this plan comes from");
            return false;
        }
        act = (io.github.agentsoz.vaccination.jack.DoActOnVaccinationDecision) __a.findEvent("io.github.agentsoz.vaccination.jack.DoActOnVaccinationDecision");
        if (act == null) {
            warning("DoActOnVaccinationDecision act: is not found in the capability/agent this plan comes from");
            return false;
        }
        return true;
    }
    
    public aos.jack.jak.plan.Plan freeze()
    {
        return this;
    }
    
    public aos.jack.jak.plan.Plan unfreeze()
    {
        return this;
    }
    
    public java.lang.Object genObject(int __index)
    {
        switch (__index) {
        }
        aos.jack.jak.core.Jak.error("illegal Object Construction");
        return null;
    }
    
    public aos.jack.jak.cursor.Cursor genCursor(int __index)
        throws java.lang.Exception
    {
        switch (__index) {
        }
        aos.jack.jak.core.Jak.error("illegal Cursor Construction");
        return null;
    }
    
    public aos.jack.jak.fsm.FSM genFSM(int __index)
        throws java.lang.Exception
    {
        switch (__index) {
        }
        aos.jack.jak.core.Jak.error("illegal FSM Construction");
        return null;
    }
    
    public boolean testCondition(int __index)
        throws java.lang.Exception
    {
        switch (__index) {
        }
        aos.jack.jak.core.Jak.error("illegal test Construction");
        return false;
    }
    
    public aos.jack.jak.plan.PlanFSM fail()
    {
        return new io.github.agentsoz.vaccination.jack.ConsiderVaccination.__failFSM();
    }
    
    public aos.jack.jak.plan.PlanFSM pass()
    {
        return new io.github.agentsoz.vaccination.jack.ConsiderVaccination.__passFSM();
    }
    
    public aos.jack.jak.plan.PlanFSM body()
    {
        return new io.github.agentsoz.vaccination.jack.ConsiderVaccination.__bodyFSM();
    }
    
    private ConsiderVaccination(io.github.agentsoz.vaccination.jack.DoConsiderVaccination __ev, aos.jack.jak.task.Task __t, io.github.agentsoz.vaccination.jack.ConsiderVaccination __env)
    {
        this(__t,__env);
        this.event = __ev;
    }
    
    protected aos.jack.jak.logic.Signature eventSignature(int __log)
    {
        return event.getSignature(__log);
    }
    
    public java.lang.String handledEvent()
    {
        return "io.github.agentsoz.vaccination.jack.DoConsiderVaccination";
    }
    
    public boolean __relevant(aos.jack.jak.event.Event __e)
    {
        return __ns.isEnabled() && relevant(((io.github.agentsoz.vaccination.jack.DoConsiderVaccination) __e));
    }
    
    public aos.jack.jak.plan.Plan createPlan(aos.jack.jak.event.Event __e, aos.jack.jak.task.Task __t)
    {
        if (!(__e instanceof io.github.agentsoz.vaccination.jack.DoConsiderVaccination)) 
            return null;
        io.github.agentsoz.vaccination.jack.DoConsiderVaccination __e1 = (io.github.agentsoz.vaccination.jack.DoConsiderVaccination) __e;
        return new io.github.agentsoz.vaccination.jack.ConsiderVaccination(__e1,__t,this);
    }
    
    public java.lang.String[] variableNames()
    {
        return __planVariableNames;
    }
    
    public java.lang.String[] variableTypes()
    {
        return __planVariableTypes;
    }
    
    public java.lang.Object getVariable(int n)
    {
        switch (n) {
            case 0: 
            {
                return aos.util.ToObject.box(event);
            }
            case 1: 
            {
                return aos.util.ToObject.box(act);
            }
            default: 
            {
                throw new java.lang.IndexOutOfBoundsException("Plan " + this + " does not have variable number " + n);
            }
        }
    }
    
    public java.lang.String[] reasoningMethods()
    {
        return mergeReasoningMethods(__reasoningMethods,super.reasoningMethods());
    }
    
    public aos.jack.jak.cursor.Cursor context()
    {
        try {
            return (((true)?aos.jack.jak.cursor.Cursor.trueCursor:aos.jack.jak.cursor.Cursor.falseCursor));
        }
        catch (java.lang.Exception e) {
            e.printStackTrace();
            return aos.jack.jak.cursor.Cursor.falseCursor;
        }
    }
    
    class __failFSM extends aos.jack.jak.plan.PlanFSM implements aos.jack.jak.core.Generator {
        private int __breakLevel = 0;
        public int run(int __status)
            throws java.lang.Throwable
        {
            do {
                try {
                    if (__tothrow != null) 
                        throw __tothrow;
                    if ((aos.jack.jak.core.Jak.debugging & aos.jack.jak.core.Jak.LOG_PLANS) != 0) 
                        aos.util.logging.LogMsg.log(this,aos.jack.jak.core.Jak.LOG_PLANS,__task + "-ConsiderVaccination.fail:" + java.lang.Integer.toString(__state));
                    if (__task.nsteps > 0) {
                        __task.nsteps-- ;
                        if (__task.nsteps == 0) 
                            agent.changeFocus();
                    }
                    if (__state < 10) {
                        __status = super.stdrun(io.github.agentsoz.vaccination.jack.ConsiderVaccination.this,__status);
                        if (__status != CONTINUE || agent.changing_focus) 
                            return __status;
                        continue;
                    }
                    __curstate = __state;
                    switch (__state) {
                        default: 
                        {
                            aos.jack.jak.core.Jak.error("ConsiderVaccination.fail: Illegal state");
                            return FAILED_STATE;
                        }
                        //* (58) 	       Log.debug(getAgent().getBasename()+":" + this.getClass().getName() + " failed!");
                        case 10: 
                        {
                            __breakLevel = 0;
                            __state = 11;
                            io.github.agentsoz.vaccination.Log.debug(getAgent().getBasename() + ":" + this.getClass().getName() + " failed!");
                            break;
                        }
                        //* (57) 	#reasoning method fail () {
                        case 11: 
                        {
                            if (__pending == null) 
                                __state = PASSED_STATE;
                            __tothrow = __pending;
                            break;
                        }
                    }
                }
                catch (java.lang.Throwable e) {
                    handleException(e,__exMap_fail);
                }
            }
             while (!agent.changing_focus);
            return CONTINUE;
        }
        
        public java.lang.String methodName()
        {
            return "fail";
        }
        
        __failFSM()
        {
        }
        
        public java.lang.String stateInfo()
        {
            int n = __curstate;
            java.lang.String file = __tt__fail[0];
            java.lang.String method = __tt__fail[1];
            if (n < 0) 
                n = -n;
            n -= (10 - 2);
            java.lang.String line = (n < 2)?"??":__tt__fail[n];
            return file + ":" + line + " " + method + " [" + __curstate + "]";
        }
        
        public java.lang.Object genObject(int __index)
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal Object Construction");
            return null;
        }
        
        public aos.jack.jak.cursor.Cursor genCursor(int __index)
            throws java.lang.Exception
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal Cursor Construction");
            return null;
        }
        
        public aos.jack.jak.fsm.FSM genFSM(int __index)
            throws java.lang.Exception
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal FSM Construction");
            return null;
        }
        
        public boolean testCondition(int __index)
            throws java.lang.Exception
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal test Construction");
            return false;
        }
        
        public aos.jack.jak.plan.Plan getPlan()
        {
            return io.github.agentsoz.vaccination.jack.ConsiderVaccination.this;
        }
        
        public void enter()
        {
            __trace = agent.trace("io.github.agentsoz.vaccination.jack.ConsiderVaccination.fail");
        }
        
    }
    class __passFSM extends aos.jack.jak.plan.PlanFSM implements aos.jack.jak.core.Generator {
        private int __breakLevel = 0;
        public int run(int __status)
            throws java.lang.Throwable
        {
            do {
                try {
                    if (__tothrow != null) 
                        throw __tothrow;
                    if ((aos.jack.jak.core.Jak.debugging & aos.jack.jak.core.Jak.LOG_PLANS) != 0) 
                        aos.util.logging.LogMsg.log(this,aos.jack.jak.core.Jak.LOG_PLANS,__task + "-ConsiderVaccination.pass:" + java.lang.Integer.toString(__state));
                    if (__task.nsteps > 0) {
                        __task.nsteps-- ;
                        if (__task.nsteps == 0) 
                            agent.changeFocus();
                    }
                    if (__state < 10) {
                        __status = super.stdrun(io.github.agentsoz.vaccination.jack.ConsiderVaccination.this,__status);
                        if (__status != CONTINUE || agent.changing_focus) 
                            return __status;
                        continue;
                    }
                    __curstate = __state;
                    switch (__state) {
                        default: 
                        {
                            aos.jack.jak.core.Jak.error("ConsiderVaccination.pass: Illegal state");
                            return FAILED_STATE;
                        }
                        //* (62) 	       Log.debug(getAgent().getBasename()+":" + this.getClass().getName() + " passed");
                        case 10: 
                        {
                            __breakLevel = 0;
                            __state = 11;
                            io.github.agentsoz.vaccination.Log.debug(getAgent().getBasename() + ":" + this.getClass().getName() + " passed");
                            break;
                        }
                        //* (61) 	#reasoning method pass () {
                        case 11: 
                        {
                            if (__pending == null) 
                                __state = PASSED_STATE;
                            __tothrow = __pending;
                            break;
                        }
                    }
                }
                catch (java.lang.Throwable e) {
                    handleException(e,__exMap_pass);
                }
            }
             while (!agent.changing_focus);
            return CONTINUE;
        }
        
        public java.lang.String methodName()
        {
            return "pass";
        }
        
        __passFSM()
        {
        }
        
        public java.lang.String stateInfo()
        {
            int n = __curstate;
            java.lang.String file = __tt__pass[0];
            java.lang.String method = __tt__pass[1];
            if (n < 0) 
                n = -n;
            n -= (10 - 2);
            java.lang.String line = (n < 2)?"??":__tt__pass[n];
            return file + ":" + line + " " + method + " [" + __curstate + "]";
        }
        
        public java.lang.Object genObject(int __index)
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal Object Construction");
            return null;
        }
        
        public aos.jack.jak.cursor.Cursor genCursor(int __index)
            throws java.lang.Exception
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal Cursor Construction");
            return null;
        }
        
        public aos.jack.jak.fsm.FSM genFSM(int __index)
            throws java.lang.Exception
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal FSM Construction");
            return null;
        }
        
        public boolean testCondition(int __index)
            throws java.lang.Exception
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal test Construction");
            return false;
        }
        
        public aos.jack.jak.plan.Plan getPlan()
        {
            return io.github.agentsoz.vaccination.jack.ConsiderVaccination.this;
        }
        
        public void enter()
        {
            __trace = agent.trace("io.github.agentsoz.vaccination.jack.ConsiderVaccination.pass");
        }
        
    }
    class __bodyFSM extends aos.jack.jak.plan.PlanFSM implements aos.jack.jak.core.Generator {
        io.github.agentsoz.vaccination.jack.Householder __local__5_0;
        java.lang.String __local__5_1;
        private int __breakLevel = 0;
        public int run(int __status)
            throws java.lang.Throwable
        {
            do {
                try {
                    if (__tothrow != null) 
                        throw __tothrow;
                    if ((aos.jack.jak.core.Jak.debugging & aos.jack.jak.core.Jak.LOG_PLANS) != 0) 
                        aos.util.logging.LogMsg.log(this,aos.jack.jak.core.Jak.LOG_PLANS,__task + "-ConsiderVaccination.body:" + java.lang.Integer.toString(__state));
                    if (__task.nsteps > 0) {
                        __task.nsteps-- ;
                        if (__task.nsteps == 0) 
                            agent.changeFocus();
                    }
                    if (__state < 10) {
                        __status = super.stdrun(io.github.agentsoz.vaccination.jack.ConsiderVaccination.this,__status);
                        if (__status != CONTINUE || agent.changing_focus) 
                            return __status;
                        continue;
                    }
                    __curstate = __state;
                    switch (__state) {
                        default: 
                        {
                            aos.jack.jak.core.Jak.error("ConsiderVaccination.body: Illegal state");
                            return FAILED_STATE;
                        }
                        //* (24) 		Householder agent = (Householder)getAgent();
                        case 10: 
                        {
                            __breakLevel = 0;
                            __local__5_0 = (io.github.agentsoz.vaccination.jack.Householder) getAgent();
                            __state = 11;
                            break;
                        }
                        //* (27) 		String decision = randomDecision();
                        case 11: 
                        {
                            __local__5_1 = randomDecision();
                            __state = 12;
                            break;
                        }
                        //* (30) 		agent.setDeliberationDecision(decision);
                        case 12: 
                        {
                            __state = 13;
                            // Save the decision 

                            __local__5_0.setDeliberationDecision(__local__5_1);
                            break;
                        }
                        //* (33) 		act.post();
                        case 13: 
                        {
                            __task.push(act.post());
                            __state = -__state;
                            __subtask_pass = 14;
                            __subtask_fail = 4;
                            return SUBTASK;
                        }
                        //* (22) 	body() {
                        case 14: 
                        {
                            if (__pending == null) 
                                __state = PASSED_STATE;
                            __tothrow = __pending;
                            break;
                        }
                    }
                }
                catch (java.lang.Throwable e) {
                    handleException(e,__exMap_body);
                }
            }
             while (!agent.changing_focus);
            return CONTINUE;
        }
        
        public java.lang.String methodName()
        {
            return "body";
        }
        
        __bodyFSM()
        {
        }
        
        public java.lang.String stateInfo()
        {
            int n = __curstate;
            java.lang.String file = __tt__body[0];
            java.lang.String method = __tt__body[1];
            if (n < 0) 
                n = -n;
            n -= (10 - 2);
            java.lang.String line = (n < 2)?"??":__tt__body[n];
            return file + ":" + line + " " + method + " [" + __curstate + "]";
        }
        
        public java.lang.Object genObject(int __index)
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal Object Construction");
            return null;
        }
        
        public aos.jack.jak.cursor.Cursor genCursor(int __index)
            throws java.lang.Exception
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal Cursor Construction");
            return null;
        }
        
        public aos.jack.jak.fsm.FSM genFSM(int __index)
            throws java.lang.Exception
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal FSM Construction");
            return null;
        }
        
        public boolean testCondition(int __index)
            throws java.lang.Exception
        {
            switch (__index) {
            }
            aos.jack.jak.core.Jak.error("illegal test Construction");
            return false;
        }
        
        public aos.jack.jak.plan.Plan getPlan()
        {
            return io.github.agentsoz.vaccination.jack.ConsiderVaccination.this;
        }
        
        protected aos.jack.jak.fsm.FSM fail()
        {
            return getPlan().fail();
        }
        
        protected aos.jack.jak.fsm.FSM pass()
        {
            return getPlan().pass();
        }
        
        public void enter()
        {
            __trace = agent.trace("io.github.agentsoz.vaccination.jack.ConsiderVaccination.body");
        }
        
        public java.lang.Object getVariable(int n)
        {
            switch (n) {
                case 0: 
                {
                    return aos.util.ToObject.box(__local__5_0);
                }
                case 1: 
                {
                    return aos.util.ToObject.box(__local__5_1);
                }
                default: 
                {
                    throw new java.lang.IndexOutOfBoundsException("Reasoning Method " + methodName() + " does not have variable number " + n);
                }
            }
        }
        
        public java.lang.String[] variableNames()
        {
            return __fsmVariableNames_body;
        }
        
        public java.lang.String[] variableTypes()
        {
            return __fsmTypes_body;
        }
        
        public java.lang.String[] variableLocalNames()
        {
            return __fsmLocalNames_body;
        }
        
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy