Skip to content

Commit

Permalink
clean results
Browse files Browse the repository at this point in the history
  • Loading branch information
hlefebvr committed Oct 28, 2023
1 parent 69d777d commit eeb0ee0
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 136 deletions.
12 changes: 9 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
add_subdirectory(generalized-assignment-problem)
add_subdirectory(knapsack-problem)
add_subdirectory(facility-location-problem)
function(ADD_EXAMPLE NAME)
add_executable(example_${NAME} ${NAME}.example.cpp)
target_link_libraries(example_${NAME} PRIVATE idol)
add_custom_command(TARGET example_${NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}.data.txt $<TARGET_FILE_DIR:example_${NAME}>)
endfunction()

add_example(knapsack)
add_example(facility)
add_example(assignment)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,19 @@
#include <iostream>
#include "idol/modeling.h"
#include "idol/problems/generalized-assignment-problem/GAP_Instance.h"
#include "idol/optimizers/column-generation/Optimizers_ColumnGeneration.h"
#include "idol/optimizers/column-generation/ColumnGeneration.h"
#include "idol/optimizers/branch-and-bound/node-selection-rules/factories/WorstBound.h"
#include "idol/optimizers/branch-and-bound/BranchAndBound.h"
#include "idol/optimizers/wrappers/GLPK/GLPK.h"
#include "idol/optimizers/dantzig-wolfe/DantzigWolfeDecomposition.h"
#include "idol/optimizers/column-generation/IntegerMaster.h"
#include "idol/optimizers/callbacks/RENS.h"
#include "idol/optimizers/callbacks/LocalBranching.h"
#include "idol/optimizers/callbacks/SimpleRounding.h"
#include "idol/optimizers/branch-and-bound/branching-rules/factories/MostInfeasible.h"
#include "idol/optimizers/wrappers/Mosek/Mosek.h"
#include "idol/optimizers/wrappers/HiGHS/HiGHS.h"

int main(int t_argc, const char** t_argv) {
using namespace idol;

using namespace idol;
int main(int t_argc, const char** t_argv) {

const auto instance = Problems::GAP::read_instance("/home/henri/Research/idol/tests/data/generalized-assignment-problem/GAP_instance0.txt");
const auto instance = Problems::GAP::read_instance("assignment.data.txt");

const unsigned int n_agents = instance.n_agents();
const unsigned int n_jobs = instance.n_jobs();
Expand Down Expand Up @@ -57,8 +52,8 @@ int main(int t_argc, const char** t_argv) {
model.use(BranchAndBound()
.with_node_optimizer(
DantzigWolfeDecomposition(decomposition)
.with_master_optimizer(Mosek::ContinuousRelaxation())
.with_pricing_optimizer(Mosek())
.with_master_optimizer(HiGHS::ContinuousRelaxation())
.with_pricing_optimizer(HiGHS())
.with_log_level(Info, Yellow)
.with_farkas_pricing(true)
.with_artificial_variables_cost(1e+4)
Expand All @@ -71,21 +66,7 @@ int main(int t_argc, const char** t_argv) {
.with_node_selection_rule(WorstBound())
.with_log_level(Info, Blue)
.with_log_frequency(1)
.with_callback(Heuristics::IntegerMaster().with_optimizer(Mosek()))
/*
.with_callback(Heuristics::IntegerMaster().with_optimizer(GLPK()))
.with_callback(
Heuristics::LocalBranching()
.with_optimizer(
BranchAndBound()
.with_node_optimizer(GLPK::ContinuousRelaxation())
.with_branching_rule(MostInfeasible())
.with_node_selection_rule(WorstBound())
.with_callback(Heuristics::SimpleRounding())
.with_log_level(Info, Green)
)
)
*/
.with_callback(Heuristics::IntegerMaster().with_optimizer(HiGHS()))
);

// Solve
Expand Down
6 changes: 0 additions & 6 deletions examples/facility-location-problem/CMakeLists.txt

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,18 @@
#include "idol/modeling.h"
#include "idol/problems/facility-location-problem/FLP_Instance.h"
#include "idol/optimizers/branch-and-bound/BranchAndBound.h"
#include "idol/optimizers/wrappers/Gurobi/Gurobi.h"
#include "idol/optimizers/branch-and-bound/node-selection-rules/factories/BestBound.h"
#include "idol/optimizers/branch-and-bound/branching-rules/factories/VariableBranching.h"
#include "idol/optimizers/branch-and-bound/branching-rules/factories/MostInfeasible.h"
#include "idol/optimizers/branch-and-bound/branching-rules/factories/UniformlyRandom.h"
#include "idol/optimizers/branch-and-bound/branching-rules/factories/StrongBranching.h"
#include "idol/optimizers/branch-and-bound/branching-rules/impls/strong-branching/StrongBranchingPhase.h"
#include "idol/optimizers/branch-and-bound/branching-rules/factories/PseudoCost.h"
#include "idol/optimizers/branch-and-bound/nodes/NodeVarInfo.h"
#include "idol/optimizers/branch-and-bound/node-selection-rules/factories/BestEstimate.h"
#include "idol/optimizers/wrappers/HiGHS/HiGHS.h"

int main(int t_argc, const char** t_argv) {
using namespace idol;

using namespace idol;
int main(int t_argc, const char** t_argv) {

Env env;

// Read instance
const auto instance = Problems::FLP::read_instance_1991_Cornuejols_et_al("instance.txt");
const auto instance = Problems::FLP::read_instance_1991_Cornuejols_et_al("facility.data.txt");
const unsigned int n_customers = instance.n_customers();
const unsigned int n_facilities = instance.n_facilities();

Expand Down Expand Up @@ -55,12 +48,10 @@ int main(int t_argc, const char** t_argv) {
// Set backend options
model.use(
BranchAndBound()
.with_node_optimizer(Gurobi::ContinuousRelaxation())
.with_branching_rule(
PseudoCost()
)
.with_node_selection_rule(BestEstimate())
.with_log_level(Trace, Blue)
.with_node_optimizer(HiGHS::ContinuousRelaxation())
.with_branching_rule(PseudoCost())
.with_node_selection_rule(BestEstimate())
.with_log_level(Trace, Blue)
);

model.optimize();
Expand Down
7 changes: 0 additions & 7 deletions examples/generalized-assignment-problem/CMakeLists.txt

This file was deleted.

7 changes: 0 additions & 7 deletions examples/knapsack-problem/CMakeLists.txt

This file was deleted.

4 changes: 0 additions & 4 deletions examples/knapsack-problem/instance50.txt

This file was deleted.

66 changes: 0 additions & 66 deletions examples/knapsack-problem/main.cpp

This file was deleted.

File renamed without changes.
39 changes: 39 additions & 0 deletions examples/knapsack.example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Created by henri on 06/04/23.
//
#include <iostream>
#include "idol/problems/knapsack-problem/KP_Instance.h"
#include "idol/modeling.h"
#include "idol/optimizers/wrappers/HiGHS/HiGHS.h"

using namespace idol;

int main(int t_argc, const char** t_argv) {

const auto instance = Problems::KP::read_instance("facility.data.txt");

const auto n_items = instance.n_items();

Env env;

// Create model
Model model(env);

auto x = model.add_vars(Dim<1>(n_items), 0, 1, Binary, "x");

model.add_ctr(idol_Sum(j, Range(n_items), instance.weight(j) * x[j]) <= instance.capacity());

model.set_obj_expr(idol_Sum(j, Range(n_items), -instance.profit(j) * x[j]));

// Set optimizer
model.use(HiGHS());

// Solve
model.optimize();

std::cout << "Objective value = " << model.get_best_obj() << std::endl;

std::cout << save_primal(model) << std::endl;

return 0;
}

0 comments on commit eeb0ee0

Please sign in to comment.