jadex.bdi.testcases.planlib.CNPEvaluatorPlan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-bdi Show documentation
Show all versions of jadex-applications-bdi Show documentation
The Jadex BDI applications package contain
several example applications, benchmarks and
testcases using BDI agents.
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());
}
}