Skip to content
Merged
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
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Build

on: [push]
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:

Expand Down
2 changes: 1 addition & 1 deletion extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ endif()
FetchContent_Declare(
mathoptsolverscmake
GIT_REPOSITORY https://github.com/fontanf/mathoptsolverscmake.git
GIT_TAG 7a2b2078fe6dba5f26b6ea46e525e3fe817b429a
GIT_TAG c312e55d551edd57e98edfd24d4e2330abdcbbd2
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../mathoptsolverscmake/"
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(mathoptsolverscmake)
2 changes: 1 addition & 1 deletion include/multiplechoiceknapsacksolver/algorithms/milp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "multiplechoiceknapsacksolver/solution.hpp"

#include "mathoptsolverscmake/milp.hpp"
#include "mathoptsolverscmake/mathopt.hpp"

namespace multiplechoiceknapsacksolver
{
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ target_include_directories(MultipleChoiceKnapsackSolver_milp PUBLIC
${PROJECT_SOURCE_DIR}/include)
target_link_libraries(MultipleChoiceKnapsackSolver_milp PUBLIC
MultipleChoiceKnapsackSolver
MathOptSolversCMake::milp)
MathOptSolversCMake::mathopt)
add_library(MultipleChoiceKnapsackSolver::milp ALIAS MultipleChoiceKnapsackSolver_milp)

add_library(MultipleChoiceKnapsackSolver_dyer_zemel)
Expand Down
18 changes: 14 additions & 4 deletions src/algorithms/milp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@

#include "multiplechoiceknapsacksolver/algorithm_formatter.hpp"

#ifdef CBC_FOUND
#include "mathoptsolverscmake/mathopt_cbc.hpp"
#endif
#ifdef HIGHS_FOUND
#include "mathoptsolverscmake/mathopt_highs.hpp"
#endif
#ifdef XPRESS_FOUND
#include "mathoptsolverscmake/mathopt_xpress.hpp"
#endif

using namespace multiplechoiceknapsacksolver;

namespace
{

mathoptsolverscmake::MilpModel create_milp_model(
mathoptsolverscmake::MathOptModel create_milp_model(
const Instance& instance)
{
int number_of_variables = instance.number_of_items();
int number_of_constraints = 1 + instance.number_of_groups();
int number_of_elements = 3 * instance.number_of_items();

mathoptsolverscmake::MilpModel model(
mathoptsolverscmake::MathOptModel model(
number_of_variables,
number_of_constraints,
number_of_elements);
Expand Down Expand Up @@ -92,7 +102,7 @@ MilpOutput multiplechoiceknapsacksolver::milp(

algorithm_formatter.print_header();

mathoptsolverscmake::MilpModel milp_model = create_milp_model(instance);
mathoptsolverscmake::MathOptModel milp_model = create_milp_model(instance);
std::vector<double> milp_solution;
double milp_bound = std::numeric_limits<double>::infinity();

Expand Down Expand Up @@ -171,7 +181,7 @@ MilpLinearRelaxationOutput multiplechoiceknapsacksolver::milp_linear_relaxation(

algorithm_formatter.print_header();

mathoptsolverscmake::MilpModel milp_model = create_milp_model(instance);
mathoptsolverscmake::MathOptModel milp_model = create_milp_model(instance);
for (int variable_id = 0;
variable_id < milp_model.number_of_variables();
++variable_id) {
Expand Down
Loading