Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Distributed MIP solving via MPI?

    Posted Thu August 14, 2014 08:55 AM

    Originally posted by: T_O


    Hi,

    I tried to play around with distributed MIP solving using the C callable library and MPI. The manual did not really help me as I only found a chapter talking about using the interactive optimizer with MPI. So maybe, you could tell me whether my approach is correct.

    I tried to use xdistmipex1.c on 4 nodes. So I wrote a configuration.vmc containing the 3 slave nodes:

    <?xml version="1.0"?>
    <vmc>
      <machine name="xxx.xxx.xxx.2">
        <transport type="MPI">
          <rank value="1"/>
        </transport>
      </machine>
     
      <machine name="xxx.xxx.xxx.3">
        <transport type="MPI">
           <rank value="2"/>
        </transport>
      </machine>
     
      <machine name="xxx.xxx.xxx.4">
        <transport type="MPI">
           <rank value="3"/>
        </transport>
      </machine>
    </vmc>

    I compiled the program with the following command:

    mpicc -DUSE_MPI -O3 -I /opt/cplex/cplex/include -L /opt/cplex/cplex/lib/x86-64_linux/static_pic xdistmipex1.c -o foo -l cplexdistmip -l cplex -l m

    Then I tried to run the program as follows:

    mpirun -x "LD_LIBRARY_PATH=/opt/cplex/cplex/bin/x86-64_linux" -host xxx.xxx.xxx.1 -host xxx.xxx.xxx.2 -host xxx.xxx.xxx.3 -host xxx.xxx.xxx.4 ./foo configuration.vmc /my/path/to/lseu.mps.gz

    This segfaults on all slave nodes. So my question is whether this approach is correct. Do I have to run the slaves in another way?

    The CPLEX version is 12.6.0.1.

    Best regards,
    Thomas


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Distributed MIP solving via MPI?

    Posted Thu August 14, 2014 10:14 AM

    When it comes to running the application, the chapter about distributed parallel MIP refers to the chapter explaining how to run the interactive. I agree that it is hard to infer from that how to run it as a callable library application. We should improve that.

    The way you invoked  the application will run ./foo on all machines. However, you need to run foo on the master and cplex on the worker nodes. For OpenMPI a command line like this should do the trick

    mpirun \
       -x "LD_LIBRARY_PATH=..." \
       -host xxx.xxx.xxx.1 -np 1 ./foo configuration.vmc /my/path/to/lseu.mps.gz \
       : -host xxx.xxx.xxx.2 -np 1 /path/to/cplex/binary/cplex -mpi \
       : -host xxx.xxx.xxx.3 -np 1 /path/to/cplex/binary/cplex -mpi \
       : -host xxx.xxx.xxx.4 -np 1 /path/to/cplex/binary/cplex -mpi

    mpirun has plenty of options, usually there also is an option to read this whole configuration from a file. That might be much simpler in the long run. I recommend replacing "xxx.xxx.xxx.[0-9]" by "localhost" for a first try. This eliminates one potential source of problems.

    If you use an MPI library other than OpenMPI then the command line may have look differently.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Distributed MIP solving via MPI?

    Posted Thu August 14, 2014 10:30 AM

    Originally posted by: T_O


    Thanks, Daniel!

    Seems to work as intended.

    Best regards,
    Thomas


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Distributed MIP solving via MPI?

    Posted Thu August 14, 2014 10:51 AM

    Originally posted by: T_O


    Another question:

    I just recognized that it also works fine if I omit the name-attribute in the configuration file. This makes things easier in some cases. Can I omit this without running into trouble?

    Best regards,
    Thomas


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Distributed MIP solving via MPI?

    Posted Thu August 14, 2014 04:55 PM

    The name attribute is optional. It is safe to omit it.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Distributed MIP solving via MPI?

    Posted Thu August 14, 2014 05:03 PM

    Originally posted by: T_O


    That's great, thanks for the information!

    I've written a script to run cplex on a cluster. Maybe, somone can use it:

     

    #!/bin/bash
    export LD_LIBRARY_PATH=$1/bin/x86-64_linux:$LD_LIBRARY_PATH
    if [ $OMPI_COMM_WORLD_RANK == 0 ]
            then
                    FOO_LIMIT=`expr $OMPI_COMM_WORLD_SIZE - 1`
                    FOO_TMP_FILE=`mktemp`
     
                    echo "<?xml version=\"1.0\"?>" > $FOO_TMP_FILE
                    echo "<vmc>" >> $FOO_TMP_FILE
     
                    for i in `seq 1 $FOO_LIMIT`;
                    do
                            echo "  <machine>" >> $FOO_TMP_FILE
                            echo "          <transport type=\"MPI\">" >> $FOO_TMP_FILE
                            echo "                  <rank value=\"$i\"/>" >> $FOO_TMP_FILE
                            echo "          </transport>" >> $FOO_TMP_FILE
                            echo "  </machine>" >> $FOO_TMP_FILE
                    done
     
                    echo "</vmc>" >> $FOO_TMP_FILE
     
                    $2 $FOO_TMP_FILE $3
     
                    rm $FOO_TMP_FILE
            else
                    $1/bin/x86-64_linux/cplex -mpi
    fi

     

    Just use mpirun to call it with 3 Parameters:

    1. CPLEX installation folder
    2. Binary compiled from C code (xdistmipex1.c, see above)
    3. LP/MPS/... file

    Best regards,
    Thomas


    #CPLEXOptimizers
    #DecisionOptimization