Skip to content

Commit 216087e

Browse files
committed
adding AMPL MP NL file reader
1 parent f7a84e8 commit 216087e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ option(Ipopt "Link to IPOPT libraries" ON)
4141

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

44-
option(CoinUtils "Link to CoinUtils libraries" ON)
44+
option(CoinUtils "Link to CoinUtils libraries" OFF)
4545

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

196196
if(NOT WIN32)
197197
#CoinUtils
198-
if (CoinUtils)
198+
if (CoinUtils or MP)
199199
include(ExternalProject)
200200
#CoinUtils
201201
message(STATUS "Enable CoinUtils")

examples/Gravity_test.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ using namespace gravity;
2626
#ifdef USE_MP
2727
TEST_CASE("testing readNL() function") {
2828
Model<> M;
29-
string NL_file = string(prj_dir)+"/data_sets/NL/ex4.nl";
29+
string NL_file = string(prj_dir)+"/data_sets/NL/hvycrash.nl";
3030
int status = M.readNL(NL_file);
31+
solver<> GRB(M,gurobi);
32+
double solver_time_start = get_wall_time();
33+
GRB.run();
3134
CHECK(status==0);
3235
CHECK(M.get_nb_vars()==36);
3336
CHECK(M.get_nb_cons()==30);

src/GurobiProgram.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,10 @@ void GurobiProgram::write_NLCstr(const string &fname){
10461046
assert(sense==GRB_EQUAL);/* Check what to do with inequalities */
10471047
nb_inst = c->get_nb_inst();
10481048
for (size_t i = 0; i< nb_inst; i++){
1049-
file << " " << c->get_name()+"("+c->_indices->_keys->at(i)+"):\n";
1049+
if(c->_indices)
1050+
file << " " << c->get_name()+"("+c->_indices->_keys->at(i)+"):\n";
1051+
else
1052+
file << " " << c->get_name()+"("+to_string(i)+"):\n";
10501053
file << " zero(0) = NL :\n";
10511054
int parent_id = -1;
10521055
file << c->getNLexpr(-1,parent_id,i);

0 commit comments

Comments
 (0)