Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Making AMPL use the CPLEX solver

  • 1.  Making AMPL use the CPLEX solver

    Posted 07/11/11 06:01 PM

    Originally posted by: SystemAdmin


    Dear All,

    I'm trying to get AMPL and CPLEX work on my MAC OS (which is I'm new to).
    I've installed AMPL and IBM CPLEX optimization studio, copied the file cplexamp to the AMPL folder, but still couldn't use CPLEX.
    When I run the AMPL and use "option solver cplexamp;" the terminal says: cannot find "cplexamp"!
    Any ideas what I'm missing here?

    Thanks a lot.
    Ameera
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Making AMPL use the CPLEX solver

    Posted 07/11/11 09:50 PM

    Originally posted by: SystemAdmin


    Try setting the solver as

    option solver './cplexamp';

    If this works, then the problem is that . -- the system's name for the current directory -- is not in your search path.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Making AMPL use the CPLEX solver

    Posted 07/13/11 01:09 PM

    Originally posted by: SystemAdmin


    Thanks a lot for your quick response.

    I've tried so but now when I write solve the error is:
    "Cannot invoke ./cplexamp: No such file or directory"
    I have both the cplex and the cplexamp files on the same folder with the AMPL file!
    any ideas?

    Thanks,
    Ameera
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Making AMPL use the CPLEX solver

    Posted 07/13/11 06:18 PM

    Originally posted by: SystemAdmin


    Are you invoking AMPL from a terminal in that same directory?

    At any rate, what works for me is the following. First, make sure that cplexamp has its executable attribute set (run 'chmod +x cplexamp' from a terminal in the directory where cplexamp is installed if not). Second, from a terminal (I'm assuming you have root privileges) cd to /usr/local/sbin and run 'sudo ln -s <path.to.cplexamp>/cplexamp'. To confirm that it works, open a terminal in your work directory and run 'which cplexamp'; it should respond with /usr/local/sbin/cplexamp. (Nothing sacred about using /usr/local/sbin; you just want it on your system path, and that directory works.) You should now be able to set the AMPL solver option to just 'cplexamp' (no path) and have it work.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Making AMPL use the CPLEX solver

    Posted 07/14/11 04:23 PM

    Originally posted by: SystemAdmin


    Hello Paul,

    Thanks a lot for the instructions, I've been following your steps and here is what I couldn't do:

    1. I couldn't cd to /usr/local/sbin I only have the directory /usr/local/bin, when I tried to mkdir sbin it gives me "permission denied"! (Pardon my lack of knowledge with Mac)
    2. I followed the rest of the instructions from the /bin and when I run sudo -s /Users/ameera/Desktop/AMPL/cplexamp it prints:

    Password:
    usage: cplexamp options stub -AMPL http://<assignment> ...

    Options:
    -- {end of options}
    -= {show name= possibilities}
    -? {show usage}
    -e {suppress echoing of assignments}
    -s {write .sol file (without -AMPL)}
    -v {just show version}

    3. "which cplexamp" gives me nothing at all!
    4. still can't set the solver option to cplexamp without an error :(
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Making AMPL use the CPLEX solver

    Posted 07/14/11 05:48 PM

    Originally posted by: SystemAdmin


    > Ameera wrote:
    >
    > 1. I couldn't cd to /usr/local/sbin I only have the directory /usr/local/bin, when I tried to mkdir sbin it gives me "permission denied"! (Pardon my lack of knowledge with Mac)

    You know more about a Mac than I do. I giving instructions that work on Linux and I think should work on a Mac (but I'm not positive). You don't need to create the sbin directory; you can put the symlink in /usr/local/bin. You just need to get it into any directory on the system command path. (Run 'echo $PATH' in a terminal to see the path.) Which brings me to ...

    > 2. I followed the rest of the instructions from the /bin and when I run sudo -s /Users/ameera/Desktop/AMPL/cplexamp it prints:
    >
    > Password:
    > usage: cplexamp options stub -AMPL http://<assignment> ...
    >
    > Options:
    > -- {end of options}
    > -= {show name= possibilities}
    > -? {show usage}
    > -e {suppress echoing of assignments}
    > -s {write .sol file (without -AMPL)}
    > -v {just show version}
    >

    You left out the 'ln' part; it should be 'sudo ln -s /Users/ameera/Desktop/AMPL/cplexamp'. The ln command creates the link. The -s switch says to make it a symbolic link. The 'sudo' part says 'pretend I'm the root user' (the root user being the benevolent, all-powerful demigod of the system). Sudo causes the system to prompt you for a password, which must be the password of a user considered to be a system administrator. (If this is your Mac and you have the only account on it, hopefully your password will work.)

    > 3. "which cplexamp" gives me nothing at all!

    That's expected now. After you get the link in, it should regurgitate /usr/local/bin/cplexamp (assuming you put the link into /usr/local/bin).

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Making AMPL use the CPLEX solver

    Posted 07/18/11 12:43 AM

    Originally posted by: SystemAdmin


    A million thanks Paul, it worked fine after adding the "ln".
    Now, when I type "solve" in AMPL, cplex gives me the following error:
    cplexamp: CPLEX Error 32201: ILM Error 16: CPLEX: license file not found or unreadable.
    Although I ran this in the terminal before opening the AMPL:
    "export ILOG_LICENSE_FILE=/Users/ameera/ILOG/ilm/access.ilm"
    Do you have any idea why it can't read the license?
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Making AMPL use the CPLEX solver

    Posted 07/18/11 12:47 AM

    Originally posted by: SystemAdmin


    Is you license file correct? What is the result of
    cat $ILOG_LICENSE_FILE
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Making AMPL use the CPLEX solver

    Posted 07/14/11 03:19 AM

    Originally posted by: SystemAdmin


    When you go to the directory that contains cplexamp, what is the output of
    ./cplexamp -v
    

    If you go to a directory that does not contain cplexamp, what is the output of
    which cplexamp
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Making AMPL use the CPLEX solver

    Posted 07/14/11 04:27 PM

    Originally posted by: SystemAdmin


    Hello Daniel,

    Thanks a lot for your reply.

    1. Here is what I got for ./cplexamp -v:

    IBM ILOG License Manager: "IBM ILOG Optimization Suite for Academic Initiative" is accessing CPLEX 12 with option(s): "e m b q ".
    AMPL/CPLEX 12.2.0.0 (Darwin 9.8.0), driver(20100512), ASL(20100130)
    Copyright IBM Corporation 1988, 2010. Copyright Lucent Technologies and others 1990, 2010. All Rights Reserved.
    5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55

    2. "which cplexamp" give me nothing either if I run it from a directory that contain cplexamp or not!

    Thanks,
    Ameera
    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: Making AMPL use the CPLEX solver

    Posted 07/18/11 12:46 AM

    Originally posted by: SystemAdmin


    This means that cplexamp is not in your PATH. You should add the directory containing cplexamp to your PATH variable:
    export PATH=/directory/to/cplexamp:$PATH
    

    After this 'which cplexamp' should find the cplexamp binary.
    #CPLEXOptimizers
    #DecisionOptimization


  • 12.  Re: Making AMPL use the CPLEX solver

    Posted 07/18/11 01:24 AM

    Originally posted by: SystemAdmin


    Thanks Daniel, Here is what I did:
    =====================
    From the terminal:
    export PATH=/Users/ameera/Desktop/AMPL:$PATH
    export ILOG_LICENSE_FILE=/Users/ameera/ILOG/ilm/access.ilm
    Now "which cplexamp" gives me:
    /Users/ameera/Desktop/AMPL/cplexamp
    And "cat $ILOG_LICENSE_FILE" gives me:
    LICENSE IBM ILOG Optimization Suite for Academic Initiative
    EVAL CPLEX 12.000 01-Jul-2012 K7VWH3DAWRTJ any , options: e m b q
    EVAL OPLStudio 6.000 01-Jul-2012 F8PUJ2CMSNV5 any , options: ide
    EVAL CP-Optimizer 2.000 01-Jul-2012 U7A4N1T2M5SJ any
    EVAL Solver 6.000 01-Jul-2012 YWXE82PYSG0F any
    EVAL Scheduler 6.000 01-Jul-2012 4742Y20A80EN any
    EVAL Dispatcher 4.000 01-Jul-2012 NX7JM0620XR5 any

    I then open the ampl executable from the folder "/Users/ameera/Desktop/AMPL".
    Still "solve" gives me the same error:
    cplexamp: CPLEX Error 32201: ILM Error 16: CPLEX: license file not found or unreadable.

    Am I missing something in the steps?
    #CPLEXOptimizers
    #DecisionOptimization


  • 13.  Re: Making AMPL use the CPLEX solver

    Posted 07/18/11 05:17 PM

    Originally posted by: SystemAdmin


    I wonder if the environment is not being inherited by the process in which cplexamp runs.

    I don't know if this translates to a Mac, but on Linux I have the export ILOG_LICENSE_FILE=... line in the .bashrc file in my home directory. I have no idea if terminals in OS X run bash or not, but if not, perhaps you can search for the equivalent. Putting it there means that it is in the environment any time I start a terminal session, and any time a process spawns one.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 14.  Re: Making AMPL use the CPLEX solver

    Posted 07/23/11 03:29 PM

    Originally posted by: SystemAdmin


    Thanks a lot Paul, I did that but the same problem still exists, I found that the ".profile" do the same job on mac as the ".bashrc", but it still not working!
    What I'm gonna do now is to reinstall everything from the beginning and will see what will happen.

    Thanks everyone for your help.
    Ameera
    #CPLEXOptimizers
    #DecisionOptimization


  • 15.  Re: Making AMPL use the CPLEX solver

    Posted 09/14/11 11:36 AM

    Originally posted by: SystemAdmin


    Sorry for the very late reply. Did you start the AMPL executable from the same terminal in which you did the other stuff and in which PATH and ILOG_LICENSE_FILE were setup?
    #CPLEXOptimizers
    #DecisionOptimization