diff --git a/CMakeLists.txt b/CMakeLists.txt index 08a71085..e05e508d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,7 +195,7 @@ set(THIRDPARTY_INSTALL_PATH ${THIRDPARTY_BASE_PATH}) if(NOT WIN32) #CoinUtils -if (CoinUtils or MP) +if (CoinUtils) include(ExternalProject) #CoinUtils message(STATUS "Enable CoinUtils") diff --git a/examples/Gravity_test.cpp b/examples/Gravity_test.cpp index 74231528..7feec051 100755 --- a/examples/Gravity_test.cpp +++ b/examples/Gravity_test.cpp @@ -22,11 +22,30 @@ using namespace std; using namespace gravity; +TEST_CASE("testing Gurobi's compound NL") { + Model<> M; + M.set_name("M"); + var<> x("x", -2,2); + var<> y("y", 0,0); + var<> z("z", pi/2.,pi/2.); + var<> resvar("resvar", -10,10); + M.add(resvar); + M.add(x); + M.add(y); + M.add(z); + Constraint<> C("C"); + C = cos(cos(y) - sin(z + cos(y))) - x - 2 - resvar; + M.add(C==0); + M.max(resvar); + solver<> GRB(M,gurobi); + double solver_time_start = get_wall_time(); + GRB.run(); +} #ifdef USE_MP TEST_CASE("testing readNL() function") { Model<> M; - string NL_file = string(prj_dir)+"/data_sets/NL/hvycrash.nl"; + string NL_file = string(prj_dir)+"/data_sets/NL/camshape100.nl"; int status = M.readNL(NL_file); solver<> GRB(M,gurobi); double solver_time_start = get_wall_time(); diff --git a/include/gravity/func.h b/include/gravity/func.h index 2ac1beec..07b3a890 100755 --- a/include/gravity/func.h +++ b/include/gravity/func.h @@ -4810,6 +4810,15 @@ namespace gravity { } if(_expr){ + if(_expr->_coef != unit().eval()){ + str += " ( PLUS , -1 , +"+to_string(current_root_id)+" )\n"; + parent_id++; + str += " ( MULTIPLY , -1 , +"+to_string(parent_id)+" )\n"; + parent_id++; + current_root_id = parent_id; + str += " ( CONSTANT , " + to_string(_expr->_coef) + " , +"+to_string(parent_id)+" )\n"; + parent_id++; + } str += getNLexpr(_expr, current_root_id, parent_id, i); } return str;