Skip to content

Commit

Permalink
Improve dependency requirements (#2009)
Browse files Browse the repository at this point in the history
Several improvement centered around infeasible_problem_analysis lib.
Breaking as many PUBLIC dependency as possible in favour of PRIVATE ones
  • Loading branch information
JasonMarechal25 authored Apr 11, 2024
1 parent 5c8796b commit 96df4e8
Show file tree
Hide file tree
Showing 19 changed files with 411 additions and 387 deletions.
39 changes: 22 additions & 17 deletions src/solver/infeasible-problem-analysis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
project(infeasible-problem-analysis)

set(SRC_INFEASIBLE_PROBLEM_ANALYSIS
unfeasibility-analysis.h
constraint-slack-analysis.h
constraint-slack-analysis.cpp
variables-bounds-consistency.h
variables-bounds-consistency.cpp
unfeasible-pb-analyzer.cpp
unfeasible-pb-analyzer.h
report.h
report.cpp
constraint.h
constraint.cpp
)
include/antares/solver/infeasible-problem-analysis/unfeasibility-analysis.h
include/antares/solver/infeasible-problem-analysis/constraint-slack-analysis.h
constraint-slack-analysis.cpp
include/antares/solver/infeasible-problem-analysis/variables-bounds-consistency.h
variables-bounds-consistency.cpp
unfeasible-pb-analyzer.cpp
include/antares/solver/infeasible-problem-analysis/unfeasible-pb-analyzer.h
include/antares/solver/infeasible-problem-analysis/report.h
report.cpp
include/antares/solver/infeasible-problem-analysis/constraint.h
constraint.cpp
)

add_library(infeasible_problem_analysis ${SRC_INFEASIBLE_PROBLEM_ANALYSIS})
target_link_libraries(infeasible_problem_analysis
PUBLIC ortools::ortools sirius_solver
utils #ortools-utils, not Antares::utils
)
PRIVATE
ortools::ortools
Antares::logs
)
target_include_directories(infeasible_problem_analysis
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

install(DIRECTORY include/antares
DESTINATION "include"
)
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
/*
** Copyright 2007-2024, RTE (https://www.rte-france.com)
** See AUTHORS.txt
** SPDX-License-Identifier: MPL-2.0
** This file is part of Antares-Simulator,
** Adequacy and Performance assessment for interconnected energy networks.
**
** Antares_Simulator is free software: you can redistribute it and/or modify
** it under the terms of the Mozilla Public Licence 2.0 as published by
** the Mozilla Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** Antares_Simulator is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** Mozilla Public Licence 2.0 for more details.
**
** You should have received a copy of the Mozilla Public Licence 2.0
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
* Copyright 2007-2024, RTE (https://www.rte-france.com)
* See AUTHORS.txt
* SPDX-License-Identifier: MPL-2.0
* This file is part of Antares-Simulator,
* Adequacy and Performance assessment for interconnected energy networks.
*
* Antares_Simulator is free software: you can redistribute it and/or modify
* it under the terms of the Mozilla Public Licence 2.0 as published by
* the Mozilla Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Antares_Simulator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Mozilla Public Licence 2.0 for more details.
*
* You should have received a copy of the Mozilla Public Licence 2.0
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
#include <regex>
#include "constraint-slack-analysis.h"
#include "antares/solver/infeasible-problem-analysis/constraint-slack-analysis.h"
#include <antares/logs/logs.h>
#include "report.h"
#include "antares/solver/infeasible-problem-analysis/report.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include "ortools/linear_solver/linear_solver.h"
#pragma GCC diagnostic pop

using namespace operations_research;

Expand Down
40 changes: 20 additions & 20 deletions src/solver/infeasible-problem-analysis/constraint.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
/*
** Copyright 2007-2024, RTE (https://www.rte-france.com)
** See AUTHORS.txt
** SPDX-License-Identifier: MPL-2.0
** This file is part of Antares-Simulator,
** Adequacy and Performance assessment for interconnected energy networks.
**
** Antares_Simulator is free software: you can redistribute it and/or modify
** it under the terms of the Mozilla Public Licence 2.0 as published by
** the Mozilla Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** Antares_Simulator is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** Mozilla Public Licence 2.0 for more details.
**
** You should have received a copy of the Mozilla Public Licence 2.0
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
* Copyright 2007-2024, RTE (https://www.rte-france.com)
* See AUTHORS.txt
* SPDX-License-Identifier: MPL-2.0
* This file is part of Antares-Simulator,
* Adequacy and Performance assessment for interconnected energy networks.
*
* Antares_Simulator is free software: you can redistribute it and/or modify
* it under the terms of the Mozilla Public Licence 2.0 as published by
* the Mozilla Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Antares_Simulator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Mozilla Public Licence 2.0 for more details.
*
* You should have received a copy of the Mozilla Public Licence 2.0
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
#include <cassert>

#include "constraint.h"
#include "antares/solver/infeasible-problem-analysis/constraint.h"
#include <sstream>
#include <iomanip>
#include <algorithm>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
/*
** Copyright 2007-2024, RTE (https://www.rte-france.com)
** See AUTHORS.txt
** SPDX-License-Identifier: MPL-2.0
** This file is part of Antares-Simulator,
** Adequacy and Performance assessment for interconnected energy networks.
**
** Antares_Simulator is free software: you can redistribute it and/or modify
** it under the terms of the Mozilla Public Licence 2.0 as published by
** the Mozilla Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** Antares_Simulator is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** Mozilla Public Licence 2.0 for more details.
**
** You should have received a copy of the Mozilla Public Licence 2.0
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
* Copyright 2007-2024, RTE (https://www.rte-france.com)
* See AUTHORS.txt
* SPDX-License-Identifier: MPL-2.0
* This file is part of Antares-Simulator,
* Adequacy and Performance assessment for interconnected energy networks.
*
* Antares_Simulator is free software: you can redistribute it and/or modify
* it under the terms of the Mozilla Public Licence 2.0 as published by
* the Mozilla Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Antares_Simulator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Mozilla Public Licence 2.0 for more details.
*
* You should have received a copy of the Mozilla Public Licence 2.0
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once

#include "unfeasibility-analysis.h"

namespace operations_research
{
class MPVariable;
class MPSolver;
}

namespace Antares::Optimization
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
/*
** Copyright 2007-2024, RTE (https://www.rte-france.com)
** See AUTHORS.txt
** SPDX-License-Identifier: MPL-2.0
** This file is part of Antares-Simulator,
** Adequacy and Performance assessment for interconnected energy networks.
**
** Antares_Simulator is free software: you can redistribute it and/or modify
** it under the terms of the Mozilla Public Licence 2.0 as published by
** the Mozilla Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** Antares_Simulator is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** Mozilla Public Licence 2.0 for more details.
**
** You should have received a copy of the Mozilla Public Licence 2.0
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
* Copyright 2007-2024, RTE (https://www.rte-france.com)
* See AUTHORS.txt
* SPDX-License-Identifier: MPL-2.0
* This file is part of Antares-Simulator,
* Adequacy and Performance assessment for interconnected energy networks.
*
* Antares_Simulator is free software: you can redistribute it and/or modify
* it under the terms of the Mozilla Public Licence 2.0 as published by
* the Mozilla Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Antares_Simulator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Mozilla Public Licence 2.0 for more details.
*
* You should have received a copy of the Mozilla Public Licence 2.0
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once

#include <vector>
#include <string>

namespace Antares
{
namespace Optimization
namespace Antares::Optimization
{
enum class ConstraintType
{
Expand Down Expand Up @@ -64,5 +62,4 @@ class Constraint
std::string getTimeStepInYear() const;
std::string getBindingConstraintName() const;
};
} // namespace Optimization
} // namespace Antares
} // namespace Antares::Optimization
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2007-2024, RTE (https://www.rte-france.com)
* See AUTHORS.txt
* SPDX-License-Identifier: MPL-2.0
* This file is part of Antares-Simulator,
* Adequacy and Performance assessment for interconnected energy networks.
*
* Antares_Simulator is free software: you can redistribute it and/or modify
* it under the terms of the Mozilla Public Licence 2.0 as published by
* the Mozilla Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Antares_Simulator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Mozilla Public Licence 2.0 for more details.
*
* You should have received a copy of the Mozilla Public Licence 2.0
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once

#include <string>
#include <vector>
#include <map>

#include "constraint.h"

namespace operations_research
{
class MPVariable;
}

namespace Antares::Optimization
{
class InfeasibleProblemReport
{
public:
InfeasibleProblemReport() = delete;
explicit InfeasibleProblemReport(const std::vector<const operations_research::MPVariable*>& slackVariables);
void prettyPrint();

private:
void turnSlackVarsIntoConstraints(const std::vector<const operations_research::MPVariable*>& slackVariables);
void sortConstraints();
void trimConstraints();
void extractItems();
void logSuspiciousConstraints();

std::vector<Constraint> mConstraints;
std::map<ConstraintType, unsigned int> mTypes;
const unsigned int nbVariables = 10;
};
} // namespace Antares::Optimization
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2007-2024, RTE (https://www.rte-france.com)
* See AUTHORS.txt
* SPDX-License-Identifier: MPL-2.0
* This file is part of Antares-Simulator,
* Adequacy and Performance assessment for interconnected energy networks.
*
* Antares_Simulator is free software: you can redistribute it and/or modify
* it under the terms of the Mozilla Public Licence 2.0 as published by
* the Mozilla Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Antares_Simulator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Mozilla Public Licence 2.0 for more details.
*
* You should have received a copy of the Mozilla Public Licence 2.0
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once

#include <memory>
#include <string>

namespace operations_research
{
class MPSolver;
}
namespace Antares::Optimization
{

/*!
* Interface for all elementary analysis.
*/
class UnfeasibilityAnalysis
{
public:
UnfeasibilityAnalysis() = default;
virtual ~UnfeasibilityAnalysis() = default;

virtual void run(operations_research::MPSolver* problem) = 0;
virtual void printReport() const = 0;
virtual std::string title() const = 0;
bool hasDetectedInfeasibilityCause() const { return hasDetectedInfeasibilityCause_; }

protected:
bool hasDetectedInfeasibilityCause_ = false;
};

}
Loading

0 comments on commit 96df4e8

Please sign in to comment.