howto.rst 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ..
  2. Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
  3. McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. How to run PyPDEVS
  14. ==================
  15. There are several ways to start up a PythonPDEVS simulation. The simplest of them all is simply by running the experiment file, as discussed in the :doc:`examples` section. For completeness, this method will also be mentioned as the first option.
  16. Local simulation
  17. ----------------
  18. The simplest method is simply by running the experiment file, which looks something like::
  19. model = MyModel()
  20. sim = Simulator(model)
  21. sim.simulate()
  22. For a more elaborate approach, please see the :doc:`examples` section.
  23. Distributed simulation with MPI
  24. -------------------------------
  25. Running the MPI version requires the *mpi4py* Python module.
  26. Since version 2.1, running the MPI version was completely redesigned and severely simplified. PyPDEVS will now automatically detect the usage of MPI when the correct invocation is done.
  27. .. code-block:: bash
  28. mpirun -np 3 python experiment.py
  29. Depending on the MPI backend that is used, several additional options might be possible. Please consult the documentation of your MPI implementation for more information.
  30. Distributed simulation with PyRO
  31. --------------------------------
  32. .. versionchanged:: 2.2.0
  33. PyRO support was dropped.
  34. .. note:: This method is no longer advised or actively developed. Most special features are **only** supported on MPI due to limitations in PyRO. Furthermore, PyRO is dramatically slow in comparison to MPI.
  35. Running the PyRO version requires the *PyRO4* Python module.
  36. Starting a simulation in PyRO is almost as simple as starting it as if it was a local simulation. The only difference is that we require both a nameserver and (possibly multiple) simulation node(s).
  37. A basic version of the nameserver can be started running:
  38. .. code-block:: bash
  39. python -m Pyro4.naming
  40. As soon as this nameserver is started up, each simulation node still needs to be set up. This can be done by running the :doc:`server` file with the name of the server as a parameter. For example:
  41. .. code-block:: bash
  42. user@node-1$ python server.py 1
  43. user@node-2$ python server.py 2
  44. user@node-3$ python server.py 3
  45. The name of the server should be incremental numbers, starting from 1. The server with name 0 is reserved for the controller, as is the common naming in MPI.
  46. .. warning:: PyRO simulation is possibly started from several different folders, which might cause import problems. PyRO transfers models as pickles, so the user should make sure that the **exact** same file structure is visible for the referenced files.