1 /* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/include/catch.hpp"
7 #include "src/kernel/lmm/maxmin.hpp"
8 #include "src/surf/surf_interface.hpp"
11 namespace lmm = simgrid::kernel::lmm;
13 TEST_CASE("kernel::lmm Test on small systems", "[kernel-lmm-small-sys]")
15 lmm::System* Sys = lmm::make_new_maxmin_system(false);
17 SECTION("Basic variable weight")
20 * System under consideration:
21 * 1\times\rho_1^{1} + 1\times\rho_2^{2} + 1\times\rho_3^{3} \le 10
24 lmm::Constraint* sys_cnst = Sys->constraint_new(nullptr, 10);
25 lmm::Variable* sys_var_1 = Sys->variable_new(nullptr, 1, 0.0, 1);
26 lmm::Variable* sys_var_2 = Sys->variable_new(nullptr, 2, 0.0, 1);
27 lmm::Variable* sys_var_3 = Sys->variable_new(nullptr, 3, 0.0, 1);
29 Sys->expand(sys_cnst, sys_var_1, 1);
30 Sys->expand(sys_cnst, sys_var_2, 1);
31 Sys->expand(sys_cnst, sys_var_3, 1);
34 REQUIRE(double_equals(sys_var_1->get_value(), 5.45455, sg_maxmin_precision));
35 REQUIRE(double_equals(sys_var_2->get_value(), 2.72727, sg_maxmin_precision));
36 REQUIRE(double_equals(sys_var_3->get_value(), 1.81818, sg_maxmin_precision));