Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/search/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -589,18 +589,39 @@ create_fast_downward_library(
if(USE_LP)
find_package(Cplex 12)
if(CPLEX_FOUND)
message(STATUS "Found CPLEX: ${CPLEX_DIR}")
target_compile_definitions(lp_solver INTERFACE HAS_CPLEX)
target_link_libraries(lp_solver INTERFACE cplex::cplex)
target_sources(lp_solver INTERFACE lp/cplex_solver_interface.h lp/cplex_solver_interface.cc)
endif()


find_package(soplex 7.1.0 QUIET)
if (SOPLEX_FOUND)
message(STATUS "Found SoPlex: ${SOPLEX_INCLUDE_DIRS}")
message(STATUS "Found SoPlex: ${SOPLEX_DIR}")
target_link_libraries(lp_solver INTERFACE libsoplex)
target_compile_definitions(lp_solver INTERFACE HAS_SOPLEX)
target_sources(lp_solver INTERFACE lp/soplex_solver_interface.h lp/soplex_solver_interface.cc)
endif()

find_package(Gurobi QUIET)
if(Gurobi_FOUND)
message(STATUS "Found Gurobi: ${GUROBI_LIBRARY} ${GUROBI_INCLUDE_DIR}")
target_compile_definitions(lp_solver INTERFACE HAS_GUROBI)
target_link_libraries(lp_solver INTERFACE gurobi::gurobi)
target_sources(lp_solver INTERFACE lp/gurobi_solver_interface.h lp/gurobi_solver_interface.cc)
endif()

find_package(HiGHS CONFIG QUIET)
if(HiGHS_FOUND)
message(STATUS "Found HiGHS: ${HiGHS_DIR}")
target_compile_definitions(lp_solver INTERFACE HAS_HIGHS)
target_link_libraries(lp_solver INTERFACE highs::highs)
target_sources(lp_solver INTERFACE
lp/highs_solver_interface.h
lp/highs_solver_interface.cc
)
endif()
endif()

create_fast_downward_library(
Expand Down
44 changes: 44 additions & 0 deletions src/search/cmake/FindGurobi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Find Gurobi and export the target gurobi::gurobi
#
# Usage:
# find_package(Gurobi)
# target_link_libraries(<target> PRIVATE gurobi::gurobi)
#
# Hints:
# -DGurobi_ROOT=...
# -Dgurobi_DIR=...
# env GUROBI_HOME=... (preferred)

set(HINT_PATHS ${Gurobi_ROOT} ${gurobi_DIR} $ENV{GUROBI_HOME})

find_path(GUROBI_INCLUDE_DIR
NAMES gurobi_c.h gurobi_c++.h
HINTS ${HINT_PATHS}
PATH_SUFFIXES include
)

# For linux.
find_library(GUROBI_LIBRARY
NAMES
gurobi130 # Gurobi 13.0
gurobi110
HINTS ${HINT_PATHS}
PATH_SUFFIXES lib
)

# Check if everything was found and set Gurobi_FOUND.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Gurobi
REQUIRED_VARS GUROBI_INCLUDE_DIR GUROBI_LIBRARY
)

if(Gurobi_FOUND AND NOT TARGET gurobi::gurobi)
add_library(gurobi::gurobi UNKNOWN IMPORTED)
set_target_properties(gurobi::gurobi PROPERTIES
IMPORTED_LOCATION "${GUROBI_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${GUROBI_INCLUDE_DIR}"
)
endif()

mark_as_advanced(GUROBI_INCLUDE_DIR GUROBI_LIBRARY)
26 changes: 22 additions & 4 deletions src/search/landmarks/landmark_cost_partitioning_algorithms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,30 @@ lp::LinearProgram OptimalCostPartitioningAlgorithm::build_initial_lp() {
say that the operator's total cost must fall between 0 and the real
operator cost.
*/
lp_constraints.resize(num_rows, lp::LPConstraint(0.0, 0.0));

/*
OLD INTERFACE CODE
lp_constraints.resize(num_rows, lp::LPConstraint(0.0, 0.0));
for (size_t op_id = 0; op_id < operator_costs.size(); ++op_id) {
lp_constraints[op_id].set_lower_bound(0);
lp_constraints[op_id].set_upper_bound(operator_costs[op_id]);
}
NEW INTERFACE CODE
lp_constraints.resize(num_rows, lp::LPConstraint(lp::Sense::LE, 0.0));
for (size_t op_id = 0; op_id < operator_costs.size(); ++op_id) {
lp_constraints[op_id].set_right_hand_side(operator_costs[op_id]);
}

All variables are by default non-negative, so we only need to set the upper bounds of the constraints to the operator costs.

TODO: double check that the lower bound is indeed redundant.
*/
lp_constraints.resize(num_rows, lp::LPConstraint(lp::Sense::LE, 0.0));
for (size_t op_id = 0; op_id < operator_costs.size(); ++op_id) {
lp_constraints[op_id].set_lower_bound(0);
lp_constraints[op_id].set_upper_bound(operator_costs[op_id]);
lp_constraints[op_id].set_right_hand_side(operator_costs[op_id]);
}


/* Coefficients of constraints will be updated and recreated in each state.
We ignore them for the initial LP. */
return lp::LinearProgram(
Expand Down Expand Up @@ -295,4 +313,4 @@ double OptimalCostPartitioningAlgorithm::get_cost_partitioned_heuristic_value(
assert(lp_solver.has_optimal_solution());
return lp_solver.get_objective_value();
}
}
}
Loading
Loading