Skip to content

Commit

Permalink
Include CPLEX with Tetrisched.
Browse files Browse the repository at this point in the history
  • Loading branch information
sukritkalra committed Sep 23, 2023
1 parent 3207bbd commit 377ea12
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
15 changes: 14 additions & 1 deletion schedulers/tetrisched/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ set(TETRISCHED_SOURCE
"src/Worker.cpp"
"src/Partition.cpp"
"src/SolverModel.cpp"
"src/Solver.cpp")
"src/CPLEXSolver.cpp")


add_library(tetrisched SHARED ${TETRISCHED_SOURCE})
target_include_directories(tetrisched PRIVATE include)
target_compile_features(tetrisched PRIVATE cxx_std_17)

# Include and link CPLEX.
target_include_directories(tetrisched PRIVATE ${CPLEX_INCLUDE_DIRS})
target_link_directories(tetrisched PRIVATE ${CPLEX_LINK_DIRS})
target_link_libraries(tetrisched PRIVATE ${CPLEX_LINK_LIBRARIES})


# add_executable(tetrisched_main ${TETRISCHED_SOURCE})
# target_include_directories(tetrisched_main PRIVATE ${CPLEX_INCLUDE_DIRS})
# target_link_directories(tetrisched_main PRIVATE ${CPLEX_LINK_DIRS})
Expand All @@ -63,10 +69,17 @@ set(TETRISCHED_TESTS
add_executable(test_tetrisched ${TETRISCHED_TESTS})
target_include_directories(test_tetrisched PRIVATE include)
target_compile_features(test_tetrisched PRIVATE cxx_std_17)

# Include and link CPLEX.
target_include_directories(test_tetrisched PRIVATE ${CPLEX_INCLUDE_DIRS})
target_link_directories(test_tetrisched PRIVATE ${CPLEX_LINK_DIRS})

target_link_libraries(
test_tetrisched
PRIVATE
GTest::gtest_main
tetrisched
${CPLEX_LINK_LIBRARIES}
)

include(GoogleTest)
Expand Down
26 changes: 26 additions & 0 deletions schedulers/tetrisched/include/tetrisched/CPLEXSolver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef _TETRISCHED_CPLEX_SOLVER_HPP_
#define _TETRISCHED_CPLEX_SOLVER_HPP_

#include <ilcplex/ilocplex.h>

#include "tetrisched/Solver.hpp"

namespace tetrisched {
class CPLEXSolver : public Solver {
private:
/// The environment variable for this instance of CPLEX.
IloEnv cplexEnv;

public:
/// Create a new CPLEXSolver.
CPLEXSolver() = default;

/// Retrieve a pointer to the SolverModel.
/// The SolverModel is the interface to define STRL expressions over.
SolverModelPtr getModel() override;

/// Export the constructed model to the given file.
void exportModel(const std::string& fileName) override;
};
} // namespace tetrisched
#endif // _TETRISCHED_CPLEX_SOLVER_HPP_
13 changes: 0 additions & 13 deletions schedulers/tetrisched/include/tetrisched/Solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ class Solver {
/// Export the constructed model to the given file.
virtual void exportModel(const std::string& fileName) = 0;
};

class CPLEXSolver : public Solver {
public:
/// Create a new CPLEXSolver.
CPLEXSolver() = default;

/// Retrieve a pointer to the SolverModel.
/// The SolverModel is the interface to define STRL expressions over.
SolverModelPtr getModel() override;

/// Export the constructed model to the given file.
void exportModel(const std::string& fileName) override;
};
} // namespace tetrisched
#endif // _TETRISCHED_SOLVER_HPP_
// #ifndef _SOLVER_HPP
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "tetrisched/Solver.hpp"
#include "tetrisched/CPLEXSolver.hpp"

namespace tetrisched {
SolverModelPtr CPLEXSolver::getModel() {
Expand Down
1 change: 1 addition & 0 deletions schedulers/tetrisched/test/test_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <filesystem>

#include "tetrisched/Solver.hpp"
#include "tetrisched/CPLEXSolver.hpp"
#include "tetrisched/SolverModel.hpp"

TEST(SolverModelTypes, TestVariableConstruction) {
Expand Down

0 comments on commit 377ea12

Please sign in to comment.