Skip to content

Commit

Permalink
update CMake and reading OR-tools input file
Browse files Browse the repository at this point in the history
  • Loading branch information
dguittet committed May 3, 2024
1 parent ceba4c8 commit c004673
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
20 changes: 17 additions & 3 deletions shared/CMakeLists.txt
Expand Up @@ -174,16 +174,30 @@ endif()


if (UNIX)
set(absl_DIR $ENV{ORTOOLSDIR}/../install_universal/lib/cmake/absl)
find_package(utf8_range
HINTS "$ENV{ORTOOLSDIR}/../install_universal/lib/cmake/utf8_range"
REQUIRED
)
set(Protobuf_DIR $ENV{ORTOOLSDIR}/../install_universal/lib/cmake/protobuf)
# set(SCIP_ROOT "$ENV{ORTOOLSDIR}/../install_universal/bin")
find_package(scip
HINTS $ENV{ORTOOLSDIR}/lib/cmake/scip
REQUIRED
)
SET(CMAKE_INSTALL_PREFIX $ENV{ORTOOLSDIR}/../install_universal CACHE PATH "Install OR-Tools" FORCE)

find_package(re2
HINTS $ENV{ORTOOLSDIR}
HINTS $ENV{ORTOOLSDIR}/../install_universal
CONFIG REQUIRED)
find_package(Eigen3
HINTS $ENV{ORTOOLSDIR}
HINTS $ENV{ORTOOLSDIR}/../install_universal
CONFIG REQUIRED)
find_package(ortools
HINTS $ENV{ORTOOLSDIR}
HINTS $ENV{ORTOOLSDIR}/../install_universal
CONFIG REQUIRED)
target_link_libraries(shared ortools::ortools)
target_link_libraries(shared libscip)
elseif(MSVC)
# get absl
find_package(absl
Expand Down
33 changes: 32 additions & 1 deletion ssc/cmod_generic_system.cpp
Expand Up @@ -41,6 +41,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// for adjustment factors
#include "common.h"

// for finding paths relative to the application
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
//define something for Windows (32-bit and 64-bit, this part is common)
#ifdef _WIN64
//define something for Windows (64-bit only)
#else
//define something for Windows (32-bit only)
#endif
#elif __APPLE__
#include <CoreFoundation/CFURL.h>
#include <CoreFoundation/CFBundle.h>
#elif __linux__
// linux
#endif

static var_info _cm_vtab_generic_system[] = {
// VARTYPE DATATYPE NAME LABEL UNITS META GROUP REQUIRED_IF CONSTRAINTS UI_HINTS
{ SSC_INPUT, SSC_NUMBER, "spec_mode", "Spec mode: 0=constant CF,1=profile", "", "", "Plant", "*", "", "" },
Expand Down Expand Up @@ -266,12 +281,28 @@ class cm_generic_system : public compute_module

char input_data_path[512];
sprintf(input_data_path, "%s/test/input_cases/ortools/", std::getenv("SSCDIR"));
std::string input_dir = input_data_path;

#if __APPLE__
CFURLRef appUrlRef;
appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("ortools"), NULL, NULL);

if (appUrlRef) {
CFStringRef filePathRef = CFURLCopyPath(appUrlRef);
const char* filePath = CFStringGetCStringPtr(filePathRef, kCFStringEncodingUTF8);
input_dir = std::string(filePath);

CFRelease(filePathRef);
CFRelease(appUrlRef);

printf("directory %s\n", input_dir.c_str());
}
#endif

bool run_rolling_horizon_cases = false;

std::string results_file = "heat_valued_results_no_off_design_heat.csv";
std::string res_dir = "heat_valued_no_offdes_results_1p_gap/";
std::string input_dir = input_data_path;

// Problem set-up
ptes_chp_dispatch ptes_chp;
Expand Down

0 comments on commit c004673

Please sign in to comment.