Changes between Version 1 and Version 2 of Java API

Show
Ignore:
Timestamp:
09/04/12 12:31:15 (13 years ago)
Author:
jorisborgdorff
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Java API

    v1 v2  
     1[[PageOutline]] 
     2 
    13== About the API == 
    24 
     
    4446The advantage of the first method is that it is type-safe, so there is no need to cast the data. Also if the code and the configuration file do not match this is detected immediately. The advantage of the second method is that it is less verbose and leads to smaller classes. 
    4547 
     48A ConduitExit is used for receiving in a blocking mode. There are two receive methods: receive() and receiveObservation(). In the first case only the data is received. In the second, an observation is received, which contains the data but also the timestamp at which the data was sent, and the timestamp at which the next message will arrive. So, 
     49{{{ 
     50double[] dataA = exitA.receive(); 
     51}}} 
     52or 
     53{{{ 
     54Observation<double[]> obsA = exitA.receiveObservation(); 
     55double[] dataA = obsA.getData(); 
     56Timestamp time = obsA.getTimestamp(); 
     57}}} 
     58 
     59A ConduitEntrance has several different send functions. The most basic send(data) sends the data and deduces the timestamp at which the data is sent, by adding delta T of the timescale to the previous timestamp. If the instance is dimensionless, or if required, you can explicitly set the timestamp of the data, and the timestamp at which you send the next message with send(data, time, nextTime): 
     60{{{ 
     61Timestamp time = Timestamp.ZERO; 
     62Timestamp nextTime = new Timestamp(2.0); 
     63entranceA.send(data, time, nextTime); 
     64}}} 
     65Finally, a muscle.core.model.Observation object can also be sent and it contains the same information: data, a time and the next time. 
     66{{{ 
     67Observation<double[]> obs = new Observation<double[]>(data, time, nextTime); 
     68entranceA.send(obs); 
     69}}} 
     70 
     71Although the entrance is automatically closed once the instance is finished, it is also possible to close the conduit earlier. 
     72 
    4673=== Parameters === 
    4774 
     
    6693 
    6794== MUSCLE MML API == 
     95 
     96=== Submodels === 
     97 
     98In MML, submodels are governed by a Submodel Execution Loop. Interpreting this for MUSCLE, this looks like: 
     99{{{ 
     100while (true) { 
     101    state, timeOrigin = init(t0) // we are allowed to receive messages 
     102    while not endCondition() { 
     103        intermediateObservation() // we are allowed to send messages 
     104        state = solvingStep() // we are allowed to receive messages 
     105    } 
     106    finalObservation() // we are allowed to send messages 
     107    if  not restartSubmodel() { 
     108        break 
     109    } 
     110} 
     111}}} 
     112Step by step, a submodel can be restarted any number of times depending on the couplings, this is what the outer loop does. Next, each time a submodel is run, it has an initialization phase where it determines the initial state and what the simulation time of this initial state should be. Then it enters a while loop while some end condition is not met. Each iteration it sends some observation of the state, and it computes the next state. When the end condition is met, it is possible to do some cleaning and to send a final observation. At the end of the submodel it decides whether it should restart. 
     113 
     114In MUSCLE, endCondition is implemented as the willStop() method, which looks at all the messages sent and received and the message with the highest simulation time is compared with the total time in the timescale of the submodel, with parameter "submodelName:T". 
    68115 
    69116== MUSCLE free-form API ==