Decision Optimization

 View Only
  • 1.  How to run multiple instances of the same model in parallel?

    Posted Fri April 22, 2022 10:56 AM
    Dears,

    I have a question on parallel processing using OPL. I have a model which consumes time to be solved. I need to run the model for multiple scenarios however, if I do this in series, it will take very long time to get the results. How can I run the same model for multiple scenarios in parallel (how to assign a CPU core for each scenario).

    Thanks in advance,

    ------------------------------
    Mohamed Awad
    ------------------------------


  • 2.  RE: How to run multiple instances of the same model in parallel?

    Posted Fri April 22, 2022 12:51 PM
    Dear Mohammed,

    The easiest way would be to create a shell script that will launch oplrun processes in parallel. 
    But if you know about gnu make, you can create makefile targets to run oplrun for each experiment and invoke 'make -j<njobs>  <targets>' to execute  <njobs> targets concurrently.
    I hope it helps

    ------------------------------
    Renaud Dumeur
    ------------------------------



  • 3.  RE: How to run multiple instances of the same model in parallel?

    Posted Fri April 22, 2022 01:16 PM
    Dear Renaud,

    Thank you for your kind reply. I would appreciate if you could help with more resources on how to perform a shell script for this case.

    Thanks in advance,


    ------------------------------
    Mohamed Awad
    ------------------------------



  • 4.  RE: How to run multiple instances of the same model in parallel?

    Posted Mon April 25, 2022 03:54 AM
      |   view attached
    Dear Mohamed,

    Using bash (install it with https://www.cygwin.com/install.html on windows)  which is the linux shell script language, you can use the attached scripts and specify the jobs to be performed in parallel in a file with the following format:

    foo.mod dat1.dat dat2.dat dat3.dat
    bar.mod dat1.dat dat2.dat

    where each line specifies that oplrun will be run in parallel on each (.mod .dat) pair. Launched jobs will be waited for before processing the next line.
    For each run, it will produce a log file thus the above list will produce:
    bar-dat2.log
    bar-dat1.log
    foo-dat1.log
    foo-dat2.log
    foo-dat3.log

    Please feel free to adapt this script to your needs.

    Cheers,

    ------------------------------
    Renaud Dumeur
    ------------------------------

    Attachment(s)

    sh
    script.sh   585 B 1 version