Skip to content

Commit

Permalink
try grep
Browse files Browse the repository at this point in the history
  • Loading branch information
hlefebvr committed Feb 19, 2025
1 parent 7de224a commit 7b3a166
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ jobs:
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: coverage
name: coverage__*.info

- name: Install lcov
run: sudo apt-get install lcov
Expand Down
3 changes: 3 additions & 0 deletions CMakeFiles/CMakeOutput.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The system is: Linux - 6.8.0-52-generic - x86_64
The system is: Linux - 6.8.0-52-generic - x86_64
The system is: Linux - 6.8.0-52-generic - x86_64
15 changes: 15 additions & 0 deletions CMakeFiles/CMakeSystem.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(CMAKE_HOST_SYSTEM "Linux-6.8.0-52-generic")
set(CMAKE_HOST_SYSTEM_NAME "Linux")
set(CMAKE_HOST_SYSTEM_VERSION "6.8.0-52-generic")
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")



set(CMAKE_SYSTEM "Linux-6.8.0-52-generic")
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION "6.8.0-52-generic")
set(CMAKE_SYSTEM_PROCESSOR "x86_64")

set(CMAKE_CROSSCOMPILING "FALSE")

set(CMAKE_SYSTEM_LOADED 1)
3 changes: 3 additions & 0 deletions cmake/CMakeFiles/CMakeOutput.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The system is: Linux - 6.8.0-52-generic - x86_64
The system is: Linux - 6.8.0-52-generic - x86_64
The system is: Linux - 6.8.0-52-generic - x86_64
15 changes: 15 additions & 0 deletions cmake/CMakeFiles/CMakeSystem.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(CMAKE_HOST_SYSTEM "Linux-6.8.0-52-generic")
set(CMAKE_HOST_SYSTEM_NAME "Linux")
set(CMAKE_HOST_SYSTEM_VERSION "6.8.0-52-generic")
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")



set(CMAKE_SYSTEM "Linux-6.8.0-52-generic")
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION "6.8.0-52-generic")
set(CMAKE_SYSTEM_PROCESSOR "x86_64")

set(CMAKE_CROSSCOMPILING "FALSE")

set(CMAKE_SYSTEM_LOADED 1)
71 changes: 30 additions & 41 deletions examples/robust/ccg-discrete-uncertainty.data.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
10 20
109.6 131.484
169.498 103.513
24.7946 41.8319
150.331 156.535
140.651 128.462
68.8231 66.0825
5.40097 33.6793
123.19 113.974
118.503 152.262
27.5682 125.587
36.1992
5.60365
10.0339
20.1965
17.4686
35.8237
14.8866
2.75196
36.7471
2.76135
12.0892
16.2641
11.3815
8.96618
32.1548
13.7501
0.631599
26.9407
36.4762
10.0098
0.674345 0.377274 0.60077 0.725902 0.347025 0.648906 0.635155 0.607522 0.333549 0.300607 0.416598 0.628605 0.753687 0.644812 0.405533 0.152511 0.424802 0.261078 0.50283 0.403443
0.79483 0.0798539 0.347963 0.756363 0.654002 0.484362 0.663717 0.820894 0.220568 0.548021 0.218845 0.779403 0.804299 0.507375 0.592223 0.172742 0.63654 0.0894973 0.819295 0.712606
0.988408 0.473435 0.741449 1.02582 0.420089 0.859221 0.932609 0.913111 0.206479 0.606641 0.592807 0.943148 1.05883 0.871605 0.719628 0.296455 0.735305 0.405338 0.70923 0.472351
0.801213 0.930165 1.12413 0.970236 0.281743 1.11036 0.911725 0.579372 0.840547 0.467774 0.937797 0.721997 0.961574 1.08599 0.57822 0.70739 0.533045 0.812734 0.148052 0.238144
0.033511 0.742563 0.729705 0.21527 0.807152 0.579068 0.209073 0.232984 0.91811 0.384516 0.620859 0.0675881 0.187979 0.528276 0.248045 0.699975 0.263439 0.677736 0.632054 0.831136
0.379508 0.394834 0.402656 0.338167 0.703938 0.315728 0.243857 0.475284 0.607753 0.336413 0.270847 0.38184 0.381389 0.285442 0.271919 0.405371 0.331478 0.346229 0.681973 0.748633
1.01954 0.586318 0.852622 1.08059 0.340762 0.955962 0.989606 0.914744 0.331927 0.616543 0.693984 0.966318 1.10785 0.963435 0.742256 0.385068 0.74801 0.505968 0.654321 0.385256
0.124851 0.647767 0.637432 0.198938 0.766693 0.495492 0.15157 0.278676 0.831333 0.339767 0.525301 0.137635 0.200255 0.446836 0.203461 0.614955 0.238989 0.585824 0.629149 0.796432
0.822042 0.611747 0.850139 0.920143 0.113758 0.898665 0.836445 0.683577 0.462689 0.406345 0.66767 0.759121 0.93636 0.891583 0.542633 0.376275 0.534339 0.501362 0.400407 0.172095
0.728693 0.27883 0.523355 0.749647 0.439242 0.602651 0.655937 0.692852 0.235195 0.391798 0.348472 0.692708 0.785082 0.607712 0.47688 0.0436219 0.506139 0.16976 0.61561 0.497567
7 15
107 21
154 13
62 104
40 123
74 140
4 136
49 77
16
27
23
15
23
33
32
17
14
17
32
4
29
24
0
0.89 0.08 0.96 0.18 0.06 0.71 0.99 0.92 0.31 0.58 0.88 0.87 0.42 0.88 0.31
0.63 0.32 0.65 0.17 0.26 0.52 0.67 0.63 0.08 0.5 0.58 0.57 0.18 0.57 0.15
0.29 0.82 0.39 0.69 0.77 0.45 0.15 0.18 0.53 0.65 0.39 0.12 0.54 0.35 0.55
0.25 0.62 0.77 0.61 0.62 0.06 0.52 0.35 0.41 0.25 0.74 0.35 0.61 0.71 0.38
0.52 0.48 0.98 0.56 0.51 0.26 0.78 0.62 0.4 0.03 0.94 0.61 0.66 0.91 0.34
0.49 0.49 0.96 0.56 0.51 0.23 0.75 0.59 0.39 0.02 0.91 0.58 0.65 0.89 0.34
0.83 0.54 0.55 0.32 0.46 0.8 0.75 0.79 0.4 0.81 0.47 0.72 0.14 0.48 0.46
16 changes: 13 additions & 3 deletions examples/robust/ccg-discrete-uncertainty.example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@
#include "idol/bilevel/modeling/Description.h"
#include "idol/robust/optimizers/column-and-constraint-generation/ColumnAndConstraintGeneration.h"
#include "idol/bilevel/optimizers/wrappers/MibS/MibS.h"
#include "idol/bilevel/optimizers/KKT/KKT.h"

using namespace idol;

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

Env env;

const auto instance = Problems::FLP::generate_instance_1991_Cornuejols_et_al(5, 15, 2);
std::ofstream file("ccg-discrete-uncertainty.data.txt");
file << instance;
file.close();

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

// Uncertainty set
Model uncertainty_set(env);
const double Gamma = 1;
const double Gamma = 2;
const auto xi = uncertainty_set.add_vars(Dim<2>(n_facilities, n_customers), 0., 1., Binary, 0., "xi");
uncertainty_set.add_ctr(idol_Sum(i, Range(n_facilities), idol_Sum(j, Range(n_customers), xi[i][j])) <= Gamma);

Expand Down Expand Up @@ -94,10 +100,14 @@ int main(int t_argc, const char** t_argv) {

const auto mibs = Bilevel::MibS()
.with_cplex_for_feasibility(true)
.with_file_interface(false)
.with_file_interface(true)
.with_logs(true)
;

const auto kkt = Bilevel::KKT()
.with_single_level_optimizer(Gurobi().with_logs(true))
;

model.use(
Robust::ColumnAndConstraintGeneration(robust_description, bilevel_description)
.with_initial_scenario_by_maximization(Gurobi())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ idol::Problems::FLP::Instance idol::Problems::FLP::generate_instance_1991_Cornue
const double capacity = std::uniform_real_distribution<double>(10, 160)(engine);
const double fixed_cost = fixed_cost_scaling_factor * std::uniform_real_distribution<double>(0, 90)(engine);
sum_capacities += capacity;
result.set_capacity(i, capacity);
result.set_fixed_cost(i, fixed_cost);
result.set_capacity(i, std::round(capacity));
result.set_fixed_cost(i, std::round(fixed_cost));
}

// Demands
Expand All @@ -158,14 +158,14 @@ idol::Problems::FLP::Instance idol::Problems::FLP::generate_instance_1991_Cornue

for (unsigned int j = 0 ; j < t_n_customers ; ++j) {
const double scaled_demand = demand_scaling_factor * result.demand(j);
result.set_demand(j, scaled_demand);
result.set_demand(j, std::round(scaled_demand));
}

// Per unit transportation costs
for (unsigned int i = 0, n = t_n_facilities ; i < n ; ++i) {
for (unsigned int j = 0, m = t_n_customers ; j < m ; ++j) {
const double distance = euclidean(facility_locations[i], customer_locations[j]);
result.set_per_unit_transportation_cost(i, j, distance);
result.set_per_unit_transportation_cost(i, j, std::round(distance * 1e2) / 1e2);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,21 +307,56 @@ idol::CCG::Formulation::build_feasibility_separation_problem(const idol::Point<i

add_separation_problem_constraints(result, t_first_stage_decision);

std::cout << result << std::endl;

const auto compute_range = [&](const Ctr& t_ctr) {
double lb = 0, ub = 0;
for (const auto& [var, coeff] : m_parent.get_ctr_row(t_ctr)) {
if (coeff < 0) {
lb += coeff * m_parent.get_var_lb(var);
ub += coeff * m_parent.get_var_ub(var);
} else {
lb += coeff * m_parent.get_var_ub(var);
ub += coeff * m_parent.get_var_lb(var);
double bound = 0;
const auto type = result.get_ctr_type(t_ctr);

if (type == LessOrEqual) {
bound -= result.get_ctr_rhs(t_ctr);
for (const auto& [var, coeff] : m_robust_description.uncertain_rhs(t_ctr)) {
if (coeff > 0 ) {
bound -= coeff * result.get_var_lb(var);
} else {
bound -= coeff * result.get_var_ub(var);
}
}
for (const auto& [var, coeff] : result.get_ctr_row(t_ctr)) {
if (coeff > 0) {
bound += coeff * result.get_var_ub(var);
} else {
bound += coeff * result.get_var_lb(var);
}
}
std::cout << "Bound of " << t_ctr.name() << " is " << bound << std::endl;
} else if (type == GreaterOrEqual) {
bound += result.get_ctr_rhs(t_ctr);
for (const auto& [var, coeff] : m_robust_description.uncertain_rhs(t_ctr)) {
if (coeff > 0 ) {
bound += coeff * result.get_var_ub(var);
} else {
bound += coeff * result.get_var_lb(var);
}
}
for (const auto& [var, coeff] : result.get_ctr_row(t_ctr)) {
if (coeff > 0) {
bound -= coeff * result.get_var_ub(var);
} else {
bound -= coeff * result.get_var_lb(var);
}
}
bound *= -1;
std::cout << "Bound of " << t_ctr.name() << " is " << bound << std::endl;
} else {
throw Exception("Equal constraints not yet implemented");
}
if (is_inf(lb) || is_inf(ub)) {

if (is_inf(bound) || is_inf(bound)) {
return Inf;
}
return std::abs(ub - lb);

return std::max(0., bound);
};

const auto add_slack = [&](const Ctr& t_ctr, double t_coeff) {
Expand Down

0 comments on commit 7b3a166

Please sign in to comment.