AMPL Linux error: Cannot find "cplex"

606 views
Skip to first unread message

Andrea Bustillos

unread,
Apr 19, 2018, 5:02:50 PM4/19/18
to AMPL Modeling Language
Hello community,

I have a Java project in which I use AMPL to solve an optimization problem. Im the project I have a folder name lib with all the libraries and files that due to my experience, I need within my project to be independent of outside folders:


Building my project's path so the jar file is added into the path, this structure works great on a Windows enviroment. But when I do this in Linux, using the corresponding files for this , (the image is actually from my project in linux) I get the following error: "Cannot fin cplex". My java class looks like this:

 try {

            // Interpret the two files
            ampl.read("models/diet/diet.mod");
//            ampl.readData(modelDirectory + "/diet.dat");
            
            //read Run file that connects to oracle
            ampl.read("models/diet/diet-oracle_verified.run");

            // display objective function and diet constraits
            ampl.expand(ampl.getObjective("Total_Cost"));
            ampl.expand(ampl.getConstraint("Diet"));
            
            // select solver
//            ampl.setOption("solver", "cplexamp");
            ampl.eval("option solver cplex;");
            ampl.setOption("cplex_options", "baropt");
            
            // Solve
            ampl.solve();           

            //Write results in table
//            ampl.writeTable("dietFoods");


        } finally {
            ampl.close();
        }

As you can see, I've tried using cplex and cplexamp, eve ./cplex as I've seen suggested but nothing works. Also if I comment these lines AMPL doesn't find minos either, wich is I think the default solver.


Am I missing a file in my lib folder? How can I make this work?


Thanks in advance for any suggestions,

Andrea B.


AMPL Google Group

unread,
Apr 20, 2018, 11:27:10 AM4/20/18
to Ampl Modeling Language
Hi Andrea,

Do you have the folder containing the AMPL binary in the system search path? On Linux this is usually done by adding the following line to the .bashrc file which should be at the root of your home directory.

export PATH="/full/path/to/the/folder/containing/the/ampl/binary:${PATH}"

Alternatively, with ampl.setOption("solver", "...") you can pass the complete path to the solver binary which should be in the same folder as the ampl binary.

Best regards,
Filipe

--
Filipe Brandão
am...@googlegroups.com
{#HS:564971083-5675#}
On Thu, Apr 19, 2018 at 9:03 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Hello community,

I have a Java project in which I use AMPL to solve an optimization problem. Im the project I have a folder name lib with all the libraries and files that due to my experience, I need within my project to be independent of outside folders:

Captura.JPG


Building my project's path so the jar file is added into the path, this structure works great on a Windows enviroment. But when I do this in Linux, using the corresponding files for this , (the image is actually from my project in linux) I get the following error: "Cannot fin cplex". My java class looks like this:

try {

// Interpret the two files
ampl.read("models/diet/diet.mod");
// ampl.readData(modelDirectory + "/diet.dat");
//read Run file that connects to oracle
ampl.read("models/diet/diet-oracle_verified.run");

// display objective function and diet constraits
ampl.expand(ampl.getObjective("Total_Cost"));
ampl.expand(ampl.getConstraint("Diet"));
// select solver
// ampl.setOption("solver", "cplexamp");
ampl.eval("option solver cplex;");
ampl.setOption("cplex_options", "baropt");
// Solve
ampl.solve();

//Write results in table
// ampl.writeTable("dietFoods");


} finally {
ampl.close();
}

As you can see, I've tried using cplex and cplexamp, eve ./cplex as I've seen suggested but nothing works. Also if I comment these lines AMPL doesn't find minos either, wich is I think the default solver.


Am I missing a file in my lib folder? How can I make this work?


Thanks in advance for any suggestions,

Andrea B.


--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



Reply all
Reply to author
Forward
0 new messages