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

jadex.bdi.testcases.planlib.CNPEvaluatorPlan Maven / Gradle / Ivy

Go to download

The Jadex BDI applications package contain several example applications, benchmarks and testcases using BDI agents.

There is a newer version: 2.4
Show newest version
package jadex.bdi.testcases.planlib;

import jadex.bdi.planlib.protocols.ParticipantProposal;
import jadex.bdi.runtime.Plan;

import java.util.ArrayList;
import java.util.List;

/**
 *  Evaluate the example proposals.
 */
public class CNPEvaluatorPlan extends Plan
{
	/**
	 *  The plan body.
	 */
	public void body()
	{
		ParticipantProposal[] proposals = (ParticipantProposal[])getParameterSet("proposals").getValues();
		
		// Accept all proposals >= 5
		List acceptables	= new ArrayList();
		for(int i=0; i=5)
			{
				// Insert acceptable proposal in descending order.
				int j;
				for(j=0; j ((Number)((ParticipantProposal)acceptables.get(j)).getProposal()).intValue())
						break;
				}
				acceptables.add(j, proposals[i]);
			}
		}
		
		getParameterSet("acceptables").addValues(acceptables.toArray());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy