All Forums

Re: parallel swmm and matlab


Ive been running an optimization of swmm using matlab. I was hoping to use the multistart and ga algorithms in parallel mode so I could make use of a multicore PC. I havent been able to get this running  (serial optimization is ok), since parallel calls are being made to SWMM and something is being overwritten..

What Ive tried is:

- rename SWMM5.exe in matlab folder to SWMM5_1,2,3 corresponding to the core no.

- assign the current .inp file to the current core number

- cycle through the core numbers as the optimization function calls SWMM

- Ive also renamed all the .m files which calculate the objective funcion to _1,2,3 etc

Ive noticed a .ini file in the matlab folder - does this also need to be modified?



You need to be a member of SWMM5 - Stormwater Management Model to add comments!

Join SWMM5 - Stormwater Management Model

Email me when people reply –


  • Hello everybody!, I have encountered the same issue in the last year, and because of this I have developed an open source solution to replicate the SWMM algorithm in Matlab, Python, and LabVIEW easily. I have called it MatSWMM an it is available at:

    MatSWMM can be useful to model Real-time control for urban drainage systems, extract simulation results and edit systematically a system that has been created with the SWMM platform. I hope this can be useful to fullfil the requirements of the unpleasant batch simulation problems. 

    Please check it out, and feel free to contact me ( if any doubt or suggestion appears. 

  • I saw this link on LinkedIn for connecting EPANET to MATLAB, there may be some swmm5 tips you can glean from this experience

    the LinkedIn discussion was 

    How can I linked MATLAB to EPANET?

    • Ive found a workaround for the moment, which is simply to open multiple sessions of Matlab until I have time for a proper fix! But thanks for the links

  • No, but this looks promising......thanks Bob

  • Have you tried setting the affinity of each one of your SWMM5.EXE to one CPU?  I can see how this is done in Windows Task Manager

    the above link has has more detail including this good time saving tip

    "Now if you find that running an application on a specific CPU core works well, you might want to use it again in the future. If so, chances are that you won't want to have to go through the Task Manager each time. Fortunately you can create a shortcut to launch an application with a specific affinity setting.

    For example, to launch Disk Defragmenter so that it runs only on CPU 0, you would create a shortcut with the following command line:

    C:\Windows\System32\cmd.exe /C start /affinity 1 dfrgui.exe

    To launch Disk Defragmenter on CPU 1, you would create a shortcut with the following command line:

    C:\Windows\System32\cmd.exe /C start /affinity 2 dfrgui.exe

    The number that follows the start /affinity command is called the affinity mask and is defined as a hexadecimal number. However, the CPU core number can be calculated more easily using binary numbers. For instance, the command

    C:\Windows\System32\cmd.exe /C start /affinity 3 dfrgui.exe

    will launch Disk Defragmenter on both CPU 0 and CPU 1. If you convert 3 into a binary number you will get 0011. Under the affinity mask system, processors are numbered from the right to left beginning with 0 and since there are 1's in the first two places, this indicates CPU 0 and CPU 1.

    Suppose you have a Quad core processor. If so and you use an affinity mask of 4, that will convert into binary 0100, which indicates CPU 2. If you use an affinity mask of 9, that will convert into binary 1001, which indicates CPU 0 and CPU 3.

    For more information on the start /affinity command, open a Command Prompt window and type the command

    start /?"

    Good luck in your modeling!
This reply was deleted.