diff --git a/.github/workflows/build_ubuntu.yml b/.github/workflows/build_ubuntu.yml index f20f73899..28c773b78 100644 --- a/.github/workflows/build_ubuntu.yml +++ b/.github/workflows/build_ubuntu.yml @@ -73,7 +73,7 @@ jobs: echo "XPRESSDIR=$XPRESS_DIR" >> $GITHUB_ENV echo "XPAUTH_PATH=$XPRESS_DIR/license/community-xpauth.xpr" >> $GITHUB_ENV echo "Create symbolic link for XPRESS library file because it is missing in the Python installation" - ln -s $XPRESS_DIR/lib/libxprs.so.42 $XPRESS_DIR/lib/libxprs.so + ln -s $XPRESS_DIR/lib/libxprs.so.42 $XPRESS_DIR/lib/libxprs.so - name: Update alternatives #mpicxx uses "g++" so we need g++ to be symbolic link to g++-10 diff --git a/.github/workflows/ubuntu-system-deps-build.yml b/.github/workflows/ubuntu-system-deps-build.yml index 52f916054..610d3336e 100644 --- a/.github/workflows/ubuntu-system-deps-build.yml +++ b/.github/workflows/ubuntu-system-deps-build.yml @@ -37,6 +37,17 @@ jobs: python -m pip install --upgrade pip pip install -r requirements-tests.txt + - name: Set-up Xpress with pip for Ubuntu + shell: bash + run: | + python -m pip install "xpress>=9.2,<9.3" + echo ${{ env.pythonLocation }} + XPRESS_DIR=${{ env.pythonLocation }}/lib/python${{ env.PYTHON_VERSION }}/site-packages/xpress + echo "XPRESSDIR=$XPRESS_DIR" >> $GITHUB_ENV + echo "XPAUTH_PATH=$XPRESS_DIR/license/community-xpauth.xpr" >> $GITHUB_ENV + echo "Create symbolic link for XPRESS library file because it is missing in the Python installation" + ln -s $XPRESS_DIR/lib/libxprs.so.42 $XPRESS_DIR/lib/libxprs.so + - name: Install mandatory system libraries run: | sudo apt-get update --fix-missing diff --git a/.github/workflows/windows-vcpkg-deps-build.yml b/.github/workflows/windows-vcpkg-deps-build.yml index af97b6562..b1c23269a 100644 --- a/.github/workflows/windows-vcpkg-deps-build.yml +++ b/.github/workflows/windows-vcpkg-deps-build.yml @@ -40,6 +40,16 @@ jobs: python -m pip install --upgrade pip pip install -r requirements-tests.txt + - name: Set-up Xpress with pip + shell: bash + run: | + python -m pip install --no-cache-dir "xpress>=9.2,<9.3" + XPRESS_DIR="${{ env.pythonLocation }}\Lib\site-packages\xpress" + cp -r $XPRESS_DIR/lib $XPRESS_DIR/bin + cp $XPRESS_DIR/license/community-xpauth.xpr $XPRESS_DIR/bin/xpauth.xpr + echo "XPRESSDIR=$XPRESS_DIR" >> $GITHUB_ENV + echo "$XPRESS_DIR/bin" >> $GITHUB_PATH + - name: Pre-requisites shell: cmd run: | diff --git a/src/cpp/benders/benders_core/CriterionInputDataReader.cpp b/src/cpp/benders/benders_core/CriterionInputDataReader.cpp index 17cc1a029..0fce7710d 100644 --- a/src/cpp/benders/benders_core/CriterionInputDataReader.cpp +++ b/src/cpp/benders/benders_core/CriterionInputDataReader.cpp @@ -13,14 +13,10 @@ using namespace Benders::Criterion; CriterionPattern::CriterionPattern(std::string prefix, std::string body) : prefix_(std::move(prefix)), body_(std::move(body)) {} -/** - * just do - * just cat ;) - */ -std::regex CriterionPattern::MakeRegex() const { - auto pattern = "(^" + prefix_ + "area<" + body_ + ">" + ")"; - return std::regex(pattern); +std::string CriterionPattern::Value() const { + return prefix_ + "area<" + body_ + ">"; } + const std::string &CriterionPattern::GetPrefix() const { return prefix_; } void CriterionPattern::SetPrefix(const std::string &prefix) { prefix_ = prefix; diff --git a/src/cpp/benders/benders_core/VariablesGroup.cpp b/src/cpp/benders/benders_core/VariablesGroup.cpp index c359dbf3c..8cd97d3be 100644 --- a/src/cpp/benders/benders_core/VariablesGroup.cpp +++ b/src/cpp/benders/benders_core/VariablesGroup.cpp @@ -25,15 +25,16 @@ std::vector> VariablesGroup::Indices() const { void VariablesGroup::Search() { indices_.assign(criterion_single_input_data_.size(), {}); - int var_index(0); - for (const auto& variable : all_variables_) { - int pattern_index(0); - for (const auto& single_input_data : criterion_single_input_data_) { - if (std::regex_search(variable, single_input_data.Pattern().MakeRegex())) { + int pattern_index(0); + for (const auto& single_input_data : criterion_single_input_data_) { + auto pattern = single_input_data.Pattern().Value(); + int var_index(0); + for (const auto& variable : all_variables_) { + if (variable.starts_with(pattern)) { indices_[pattern_index].push_back(var_index); } - ++pattern_index; + ++var_index; } - ++var_index; + ++pattern_index; } -} +} \ No newline at end of file diff --git a/src/cpp/benders/benders_core/include/antares-xpansion/benders/benders_core/CriterionInputDataReader.h b/src/cpp/benders/benders_core/include/antares-xpansion/benders/benders_core/CriterionInputDataReader.h index df576689a..263742609 100644 --- a/src/cpp/benders/benders_core/include/antares-xpansion/benders/benders_core/CriterionInputDataReader.h +++ b/src/cpp/benders/benders_core/include/antares-xpansion/benders/benders_core/CriterionInputDataReader.h @@ -45,7 +45,7 @@ class CriterionPattern { public: explicit CriterionPattern(std::string prefix, std::string body); CriterionPattern() = default; - [[nodiscard]] std::regex MakeRegex() const; + [[nodiscard]] std::string Value() const; [[nodiscard]] const std::string &GetPrefix() const; void SetPrefix(const std::string &prefix); [[nodiscard]] const std::string &GetBody() const; @@ -54,7 +54,6 @@ class CriterionPattern { private: std::string prefix_; std::string body_; - }; /// @brief holds the pattern and the criterion diff --git a/tests/cpp/outer_loop/outer_loop_test.cpp b/tests/cpp/outer_loop/outer_loop_test.cpp index b203a9350..e69cf673a 100644 --- a/tests/cpp/outer_loop/outer_loop_test.cpp +++ b/tests/cpp/outer_loop/outer_loop_test.cpp @@ -181,17 +181,17 @@ TEST_F(OuterLoopPatternTest, RegexGivenPrefixAndBody) { const std::string body = "body"; CriterionPattern o(prefix, body); - auto ret_regex = o.MakeRegex(); + auto ret_regex = o.Value(); - ASSERT_EQ(std::regex_search(prefix + body, ret_regex), false); - ASSERT_EQ(std::regex_search(prefix + "::" + body + "::suffix", ret_regex), + ASSERT_EQ((prefix + body).find(ret_regex) != std::string::npos, false); + ASSERT_EQ((prefix + "::" + body + "::suffix").find(ret_regex) != std::string::npos, false); - ASSERT_EQ(std::regex_search(body + prefix, ret_regex), false); - ASSERT_EQ(std::regex_search(prefix + "::", ret_regex), false); - ASSERT_EQ(std::regex_search(body, ret_regex), false); - ASSERT_EQ(std::regex_search(prefix + "area<" + body + ">", ret_regex), true); - ASSERT_EQ(std::regex_search(prefix + "area<" + body + ">::suffix", ret_regex), true); - ASSERT_EQ(std::regex_search(prefix + "area<" + body + "_other_area>::suffix", ret_regex), false); + ASSERT_EQ((body + prefix).find(ret_regex) != std::string::npos , false); + ASSERT_EQ((prefix + "::").find(ret_regex) != std::string::npos, false); + ASSERT_EQ((body).find(ret_regex) != std::string::npos, false); + ASSERT_EQ((prefix + "area<" + body + ">").find(ret_regex) != std::string::npos, true); + ASSERT_EQ((prefix + "area<" + body + ">::suffix").find(ret_regex) != std::string::npos, true); //Match + ASSERT_EQ((prefix + "area<" + body + "_other_area>::suffix").find(ret_regex) != std::string::npos, false); } class OuterLoopInputFromYamlTest : public ::testing::Test {};