Please give me a tip about algorithm involvement in Brahms Language

36 views
Skip to first unread message

abid ghaffar

unread,
May 26, 2015, 8:43:28 PM5/26/15
to brahms...@googlegroups.com
Dear Dr. Martain,

I need some comments from you regarding algorithm involvement in simulation of Brahms Model. Lets suppose, we have some scenario of some activity going on in some official environment having start/end time. Is there any algorithm involved in  while simulating the scenario? Brahms programming style is different as compared to Object Oriented Language. How would you comment about involving some algorithm (any algorithm) in Brahms Modeling and Simulation part? or there is no need for any algorithm while using Brahms Language?

Thank you and regards,

Abid Ghaffar
International Islamic University Malaysia

Maarten Sierhuis

unread,
May 29, 2015, 3:17:04 AM5/29/15
to brahms...@googlegroups.com
Dear Abid,

I am not sure if I understand your question. What I think you are asking is if you can call some algorithm form an agent during a simulation. Let me put this in some Brahms code. I hope this helps.

agent Abid {
  workframes:
     work frame wf_perform_some_algorithm {
         do {
            AlgorithmX( );
         }
     }
}

The answer is that there are many ways to do this in Brahms:

1) Use a java activity.
This means you implement the activity AlgorithmX( ) in Java and define the activity as a java activity.
(look at section 2.29 JAVA ACTIVITY (JAC)  (page 62) in the language document. You can find this PDF document in the docs folder of the Brahms installation)

Abid.b:

agent Abid {
  activities:
     java AlgorithmX( ) {
        class: "ejenta.com.AlgotithmX";
     }

  workframes:
     work frame wf_perform_some_algorithm {
         do {
            AlgorithmX( );
         }
     }
}

The Java implementation of this Java activity looks something like this:
(look at the Java API documentation AbstractExternalActivity)

AlgorithmX.java:

package ejenta.com;

public class AlgorithmX extends AbstractExternalActivity {

    /**

     * Executes the java activity action.

*/

    public void doActivity() throws ExternalException {

       ...

    }

}


2) Call a method of a Java class directly from the workframe.

(look at section 2.42 JAVA INTEGRATION (page 126) in the language document. You can find this PDF document in the docs folder of the Brahms installation)


Abid,b:


jimport ejenta.com.ClassX;

agent Abid {
  attributes:
      public boolean executedAlgorithmX
  workframes:
     workframe wf_perform_some_algorithm {
         when (unknown(current. executedAlgorithmX))
         do {
            java(ClassX) jobj = new ClassX( );
            jobj.AlgorithmX();
            conclude((current.executedAlgorithmX = true));
         }
     }
}

ClassX.java:

package ejenta.com;

public class ClassX {

   public void AlgorithmX() { ... }

}



Maarten.

abid ghaffar

unread,
May 30, 2015, 8:39:15 PM5/30/15
to brahms...@googlegroups.com
Dear Dr. Martain,

Thank you very much for the explanation regarding my question. I am asking the question in different way about Brahms Language in general. My point is, when we program in Brahms Language, do we use any algorithm or we just simulate the scenario of any activity using Brahms Language. For instance, we have some scenario of any situation and we want to simulate it using Brahms Language, do we need any algorithm for the simulation of our scenario? Do we say that we need an algorithm to convert our scenario into agent viewer program? I hope I am able to clear my question.

Thank you and regards,

Abid Ghaffar
International Islamic University, Malaysia.
Reply all
Reply to author
Forward
0 new messages