Skip to content

Commit

Permalink
Fix COIN code
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanf committed Dec 28, 2024
1 parent 68be0ab commit 7d13f09
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 60 deletions.
2 changes: 1 addition & 1 deletion extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ endif()
FetchContent_Declare(
mathoptsolverscmake
GIT_REPOSITORY https://github.com/fontanf/mathoptsolverscmake.git
GIT_TAG 80cd13a843e2c10684abbfe76cf9aae0d71ff79d
GIT_TAG 2394715172d234b21515eae6cec7c545bafa65cb
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../mathoptsolverscmake/"
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(mathoptsolverscmake)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#if CLP_FOUND
#if CBC_FOUND

#include "generalizedassignmentsolver/solution.hpp"

Expand Down
12 changes: 2 additions & 10 deletions include/generalizedassignmentsolver/algorithms/milp_cbc.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#pragma once

#if defined(CBC_FOUND) || defined(CLP_FOUND)

#include "generalizedassignmentsolver/solution.hpp"

#include <OsiCbcSolverInterface.hpp>
#include <coin/OsiCbcSolverInterface.hpp>

namespace generalizedassignmentsolver
{
Expand All @@ -24,11 +22,7 @@ struct CoinLP

}

#endif

#if CBC_FOUND

#include <CbcModel.hpp>
#include <coin/CbcModel.hpp>

namespace generalizedassignmentsolver
{
Expand Down Expand Up @@ -104,5 +98,3 @@ const MilpCbcOutput milp_cbc(
const MilpCbcParameters& parameters = {});

}

#endif
2 changes: 1 addition & 1 deletion include/generalizedassignmentsolver/algorithms/repair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace generalizedassignmentsolver
enum class RepairInitialSolution
{
CombinatorialRelaxation,
#if CLP_FOUND
#if CBC_FOUND
LinearRelaxationClp,
#endif
#if CPLEX_FOUND
Expand Down
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ target_link_libraries(GeneralizedAssignmentSolver_main PUBLIC
GeneralizedAssignmentSolver_local_search
GeneralizedAssignmentSolver_column_generation
Boost::program_options)
if(COLORINGSOLVER_USE_CBC)
if(GENERALIZEDASSIGNMENTSOLVER_USE_CBC)
target_compile_definitions(GeneralizedAssignmentSolver_main PUBLIC
CBC_FOUND=1)
target_link_libraries(GeneralizedAssignmentSolver_main PUBLIC
GeneralizedAssignmentSolver_milp_cbc)
endif()
if(COLORINGSOLVER_USE_GUROBI)
if(GENERALIZEDASSIGNMENTSOLVER_USE_GUROBI)
target_compile_definitions(GeneralizedAssignmentSolver_main PUBLIC
GUROBI_FOUND=1)
target_link_libraries(GeneralizedAssignmentSolver_main PUBLIC
GeneralizedAssignmentSolver_milp_gurobi)
endif()
if(COLORINGSOLVER_USE_CPLEX)
if(GENERALIZEDASSIGNMENTSOLVER_USE_CPLEX)
target_compile_definitions(GeneralizedAssignmentSolver_main PUBLIC
CPLEX_FOUND=1)
target_link_libraries(GeneralizedAssignmentSolver_main PUBLIC
GeneralizedAssignmentSolver_milp_cplex)
endif()
if(COLORINGSOLVER_USE_KNITRO)
if(GENERALIZEDASSIGNMENTSOLVER_USE_KNITRO)
target_compile_definitions(GeneralizedAssignmentSolver_main PUBLIC
KNITRO_FOUND=1)
target_link_libraries(GeneralizedAssignmentSolver_main PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/linrelax_clp.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if CLP_FOUND
#if CBC_FOUND

#include "generalizedassignmentsolver/algorithms/linrelax_clp.hpp"
#include "generalizedassignmentsolver/algorithms/milp_cbc.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/linrelax_clp_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if CLP_FOUND
#if CBC_FOUND

#include "generalizedassignmentsolver/tester.hpp"
#include "generalizedassignmentsolver/algorithms/linrelax_clp.hpp"
Expand Down
64 changes: 28 additions & 36 deletions src/algorithms/milp_cbc.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if defined(CBC_FOUND) || defined(CLP_FOUND)

#include "generalizedassignmentsolver/algorithms/milp_cbc.hpp"

#include "generalizedassignmentsolver/algorithm_formatter.hpp"
Expand Down Expand Up @@ -75,38 +73,34 @@ CoinLP::CoinLP(const Instance& instance)
number_of_elements_in_rows.data());
}

#endif

#if CBC_FOUND

//#include "CbcHeuristicDiveCoefficient.hpp"
//#include "CbcHeuristicDiveFractional.hpp"
//#include "CbcHeuristicDiveGuided.hpp"
//#include "CbcHeuristicDiveVectorLength.hpp"
//#include "CbcLinked.hpp"
//#include "CbcHeuristicGreedy.hpp"
//#include "CbcHeuristicLocal.hpp"
#include "CbcHeuristic.hpp"
//#include "CbcHeuristicRINS.hpp"
//#include "CbcHeuristicRENS.hpp"

//#include "CglAllDifferent.hpp"
//#include "CglClique.hpp"
//#include "CglDuplicateRow.hpp"
//#include "CglFlowCover.hpp"
//#include "CglGomory.hpp"
//#include "CglKnapsackCover.hpp"
//#include "CglLandP.hpp"
//#include "CglLiftAndProject.hpp"
//#include "CglMixedIntegerRounding.hpp"
//#include "CglMixedIntegerRounding2.hpp"
//#include "CglOddHole.hpp"
//#include "CglProbing.hpp"
//#include "CglRedSplit.hpp"
//#include "CglResidualCapacity.hpp"
//#include "CglSimpleRounding.hpp"
//#include "CglStored.hpp"
//#include "CglTwomir.hpp"
//#include "coin/CbcHeuristicDiveCoefficient.hpp"
//#include "coin/CbcHeuristicDiveFractional.hpp"
//#include "coin/CbcHeuristicDiveGuided.hpp"
//#include "coin/CbcHeuristicDiveVectorLength.hpp"
//#include "coin/CbcLinked.hpp"
//#include "coin/CbcHeuristicGreedy.hpp"
//#include "coin/CbcHeuristicLocal.hpp"
#include "coin/CbcHeuristic.hpp"
//#include "coin/CbcHeuristicRINS.hpp"
//#include "coin/CbcHeuristicRENS.hpp"

//#include "coin/CglAllDifferent.hpp"
//#include "coin/CglClique.hpp"
//#include "coin/CglDuplicateRow.hpp"
//#include "coin/CglFlowCover.hpp"
//#include "coin/CglGomory.hpp"
//#include "coin/CglKnapsackCover.hpp"
//#include "coin/CglLandP.hpp"
//#include "coin/CglLiftAndProject.hpp"
//#include "coin/CglMixedIntegerRounding.hpp"
//#include "coin/CglMixedIntegerRounding2.hpp"
//#include "coin/CglOddHole.hpp"
//#include "coin/CglProbing.hpp"
//#include "coin/CglRedSplit.hpp"
//#include "coin/CglResidualCapacity.hpp"
//#include "coin/CglSimpleRounding.hpp"
//#include "coin/CglStored.hpp"
//#include "coin/CglTwomir.hpp"

/**
* Useful links:
Expand Down Expand Up @@ -438,5 +432,3 @@ const MilpCbcOutput generalizedassignmentsolver::milp_cbc(
algorithm_formatter.end();
return output;
}

#endif
6 changes: 3 additions & 3 deletions src/algorithms/repair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "generalizedassignmentsolver/algorithm_formatter.hpp"
#include "generalizedassignmentsolver/algorithms/lagrelax_lbfgs.hpp"
#if CLP_FOUND
#if CBC_FOUND
#include "generalizedassignmentsolver/algorithms/linrelax_clp.hpp"
#endif
#if CPLEX_FOUND
Expand All @@ -22,7 +22,7 @@ std::istream& generalizedassignmentsolver::operator>>(std::istream& in, RepairIn
in >> token;
if (token == "combinatorial_relaxation") {
initial_solution = RepairInitialSolution::CombinatorialRelaxation;
#if CLP_FOUND
#if CBC_FOUND
} else if (token == "linrelax_clp") {
initial_solution = RepairInitialSolution::LinearRelaxationClp;
#endif
Expand Down Expand Up @@ -71,7 +71,7 @@ RepairOutput generalizedassignmentsolver::repair(
}
}
break;
#if CLP_FOUND
#if CBC_FOUND
} case RepairInitialSolution::LinearRelaxationClp: {
LinRelaxClpOutput output_linrelax_clp = linrelax_clp(instance);
for (ItemIdx item_id = 0; item_id < instance.number_of_items(); ++item_id) {
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "generalizedassignmentsolver/instance_builder.hpp"

#if CLP_FOUND
#if CBC_FOUND
//#include "generalizedassignmentsolver/algorithms/linrelax_clp.hpp"
#endif
#include "generalizedassignmentsolver/algorithms/column_generation.hpp"
Expand Down Expand Up @@ -103,7 +103,7 @@ Output run(
read_args(parameters, vm);
return random(instance, generator, parameters);

#if CLP_FOUND
#if CBC_FOUND
//} else if (algorithm == "linrelax-clp") {
// Parameters parameters;
// read_args(parameters, vm);
Expand Down

0 comments on commit 7d13f09

Please sign in to comment.