Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method is a responsibility of Master, not Slave #1

Open
schteppe opened this issue Jan 10, 2014 · 7 comments
Open

Method is a responsibility of Master, not Slave #1

schteppe opened this issue Jan 10, 2014 · 7 comments

Comments

@schteppe
Copy link
Member

Hi @adeas31,

Currently the slave gets instructions on what method to use, but this should be handled by the master.

Each slave provides one FMU, and exposes variables and a few methods to the Master.
The Master knows of all connected slaves, and in what order they should run doStep(). The step order is the method: sequential stepping of slaves (Jacobi), and parallel stepping of slaves (Gauss-Seidel).

This fix is needed for running several slaves, but the current code is OK for one slave.

Not sure if I can get time over to fix this, or if it is required for the workshop, but will check.

@adeas31
Copy link
Member

adeas31 commented Jan 10, 2014

You can run several slaves. Tell the master about the number of slaves you want to run (-n cli parameter). If you don't specify it then the master immediately runs the simulation as soon as the slave connects to it. If -n is specified the master waits for the all slaves to connect and then starts the simulation.

@schteppe
Copy link
Member Author

Alright... But how do the master know what method it should run? Is it possible at all to have interconnected slaves?

@adeas31
Copy link
Member

adeas31 commented Jan 10, 2014

The master calls the methods as specified in the FMI specification. In the following order,
fmiInstantiateSlave
fmiInitializeSlave
fmiGetReal
fmiSetReal
fmiDoStep
.....
fmiTerminateSlave
fmiFreeSlaveInstance

I don't see any use of exposing these methods from a slave to master since each slave should have these methods. Even if we expose them still they are going to be same for each slave. So it is not required.

@adeas31
Copy link
Member

adeas31 commented Jan 10, 2014

No, the slaves are never interconnected. They should communicate via master.

@schteppe
Copy link
Member Author

Gotcha. Let me reformulate the second question. Is it possible to have interconnected Slaves via the Master? In this case, the Master exchanges information between the slaves (Master calls getReal for SlaveA and then setReal for SlaveB).

@adeas31
Copy link
Member

adeas31 commented Jan 10, 2014

Yes and this is what exactly happening in the current code. The connection information we pass to master handles this e.g,

Pass the master following argument,
-c=1,0,0,0:

Then the master calls the getReal value reference 0 of slave1 and pass it to slave0 value reference 0 using setReal.
Note that get/setReal may change to get/setInteger,get/setBoolean etc. depending on the type of the value reference. The code currently only handles the real types. I will fix the other types today or tomorrow.

@schteppe
Copy link
Member Author

Alright! I'm slowly grasping the code structure now... As I understand it, all connections must be resolved before the master can run doStep for a slave. The Master tries to resolve all the connections and then step the slaves, right? What if I want to switch to a sequential resolve & step, is that possible?

Below are the loose coupling algorithms we have worked with (pseudo code). Which one is being used by this master?

// Parallel / Gauss-Seidel
loop {
    slaveB.setReal( 0, slaveA.getReal(1) ) // Resolve connection 1
    slaveA.setReal( 0, slaveB.getReal(1) ) // Resolve connection 2
    slaveA.doStep()
    slaveB.doStep()
}
// Sequential / Jacobi
loop {
    slaveB.setReal( 0, slaveA.getReal(1) ) // Resolve connection 1
    slaveB.doStep()
    slaveA.setReal( 0, slaveB.getReal(1) ) // Resolve connection 2
    slaveA.doStep()
}

Can I switch between the two by passing the -m flag to the slaves? I can't understand how an individual slave is able to change this simulation loop in the master. What happens if one slave is set to "jacobi" and another is set to "gs"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants