Example 03 – Operations with output parameters

Operations can have output parameters, i.e. parameters whose value is meant to be computed by the operation execution. On the agent side such parameters are managed as action feedbacks. At the API level, output parameters are represented by the class OpWithFeedbackParam<ParamType>, where ParamType must be the specific type of the output parameter.

The class provides then a set method to set the output parameter value. In the following example, an agent creates and uses a Calc artifact, by executing operations with output parameters:

MAS example03_output_param {


  calc_user agentArchClass c4jason.CAgentArch;

  classpath: "../../../lib/cartago.jar";"../../../lib/c4jason.jar";

The Calc used by the agents has the following code:

public class Calc extends Artifact {

  void sum(double a, double b, OpFeedbackParam sum){

  void sumAndSub(double a, double b, OpFeedbackParam sum,
                                     OpFeedbackParam sub){

The source code of the agent follows:


  <- makeArtifact("myCalc","c4jexamples.Calc",[]);
     println("The sum is ",Sum);
     sumAndSub(0.5, 1.5, NewSum, Sub);
     println("The new sum is ",NewSum," and the sub is ",Sub).


  • On the agent side output parameters are denoted by bound variables, which are bound with operation execution.
  • An operation can have any number of output parameters.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>