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

org.janusproject.kernel.agent.bdi.BDIPlan Maven / Gradle / Ivy

/* 
 * $Id$
 * 
 * Janus platform is an open-source multiagent platform.
 * More details on 
 * Copyright (C) 2011-2012 Janus Core Developers
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU 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 Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package org.janusproject.kernel.agent.bdi;

import java.util.Collection;
import java.util.List;

import org.janusproject.kernel.condition.ConditionnedObject;

/**
 * Represents a plan executed by a BDI agent.
 * A plan calls procedurally the execute method of his actions.
 * 
 * @author $Author: [email protected]$
 * @author $Author: ngaud$
 * @version $FullVersion$
 * @mavengroupid $Groupid$
 * @mavenartifactid $ArtifactId$
 */
public abstract class BDIPlan extends ConditionnedObject{
	/**
	 * List of actions to run in order to execute the plan
	 */
	protected final List actions;
	
	/**
	 * Constructor.
	 * @param actionList 
	 */
	public BDIPlan(List actionList) {
		this.actions = actionList;
	}

	/**
	 * Return the plan's actions.
	 * @return list of actions
	 */
	public final List getActions() {
		return this.actions;
	}
	
	/**
	 * Return the actions needed by the plan in order to run.
	 * It's mandatory to rewrite this function in the subclass.
	 * @return list of actions
	 */
	public static Collection> getRequiredActions() {
		return null;
	}

	/**
	 * Return the supported goal.
	 * @return class of the supported goal
	 */
	public abstract Class getSupportedGoalType();
	
	/**
	 * Check if a plan is relevant, i.e. can manage a goal in particular.
	 * @param goal is the goal we want to test (if it's manageable by the plan)
	 * @return true if the plan can manage the goal, false otherwise
	 */
	public abstract boolean isRelevant(Class goal);

	/**
	 * Check if a plan is applicable according to the agent's current beliefs.
	 * @param beliefs is the agent's beliefs
	 * @return true if the plan is applicable, false otherwise.
	 */
	public abstract boolean context(List beliefs);
	
	/**
	 * Execute method. Shall calls the execute method of the actions.
	 * @param actionIndex allow the execution of the currentAction
	 * @param beliefs is the agent's beliefs
	 * @return a plan status
	 */
	public abstract BDIPlanStatus execute(int actionIndex, List beliefs);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy