Skip to content

Commit

Permalink
adding AMPL MP NL file reader
Browse files Browse the repository at this point in the history
  • Loading branch information
hhijazi committed Apr 18, 2024
1 parent f7a84e8 commit 216087e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ option(Ipopt "Link to IPOPT libraries" ON)

option(MP "Link to AMPL MP libraries" OFF)

option(CoinUtils "Link to CoinUtils libraries" ON)
option(CoinUtils "Link to CoinUtils libraries" OFF)

# Find XLNT (optional)
option(Xlnt "Link to XLNT libraries" OFF)
Expand Down Expand Up @@ -195,7 +195,7 @@ set(THIRDPARTY_INSTALL_PATH ${THIRDPARTY_BASE_PATH})

if(NOT WIN32)
#CoinUtils
if (CoinUtils)
if (CoinUtils or MP)
include(ExternalProject)
#CoinUtils
message(STATUS "Enable CoinUtils")
Expand Down
5 changes: 4 additions & 1 deletion examples/Gravity_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ using namespace gravity;
#ifdef USE_MP
TEST_CASE("testing readNL() function") {
Model<> M;
string NL_file = string(prj_dir)+"/data_sets/NL/ex4.nl";
string NL_file = string(prj_dir)+"/data_sets/NL/hvycrash.nl";
int status = M.readNL(NL_file);
solver<> GRB(M,gurobi);
double solver_time_start = get_wall_time();
GRB.run();
CHECK(status==0);
CHECK(M.get_nb_vars()==36);
CHECK(M.get_nb_cons()==30);
Expand Down
5 changes: 4 additions & 1 deletion src/GurobiProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,10 @@ void GurobiProgram::write_NLCstr(const string &fname){
assert(sense==GRB_EQUAL);/* Check what to do with inequalities */
nb_inst = c->get_nb_inst();
for (size_t i = 0; i< nb_inst; i++){
file << " " << c->get_name()+"("+c->_indices->_keys->at(i)+"):\n";
if(c->_indices)
file << " " << c->get_name()+"("+c->_indices->_keys->at(i)+"):\n";
else
file << " " << c->get_name()+"("+to_string(i)+"):\n";
file << " zero(0) = NL :\n";
int parent_id = -1;
file << c->getNLexpr(-1,parent_id,i);
Expand Down

0 comments on commit 216087e

Please sign in to comment.