Revision 61c70cc2309b155b4f4dc31a92ce60373b073c1e authored by Max Göttlicher on 26 April 2023, 13:35:20 UTC, committed by Max Göttlicher on 26 April 2023, 13:35:20 UTC
1 parent c54e504
gurobi_solve.hpp
//
// Created by max on 25.07.22.
//
#ifndef PDS_GUROBI_SOLVE_HPP
#define PDS_GUROBI_SOLVE_HPP
#include <range/v3/all.hpp>
#include "pds.hpp"
// Forward declaration to avoid full gurobi header inclusion
struct GRBModel;
struct GRBVar;
struct GRBEnv;
namespace pds {
inline const double TIME_LIMIT = 10 * 60;
struct MIPModel {
std::unique_ptr<GRBModel> model;
map<PowerGrid::VertexDescriptor, GRBVar> xi;
MIPModel();
MIPModel(MIPModel&& other) = default;
virtual ~MIPModel();
};
void preloadMIPSolver();
GRBEnv& getEnv();
void relaxMIPModel(MIPModel&);
MIPModel modelJovanovic(PdsState& state);
MIPModel modelJovanovicExpanded(PdsState& state);
MIPModel modelDomination(PdsState& state);
MIPModel modelBrimkov(PdsState& state);
MIPModel modelBrimkovExpanded(PdsState& state);
MIPModel modelAzamiBrimkov(PdsState& state);
SolveResult solveMIP(MIPModel&, bool output = false, double timeLimit = TIME_LIMIT);
void applySolution(PdsState&, MIPModel& model);
template<class F = decltype(modelJovanovicExpanded)>
//requires std::is_invocable_v<PdsState&>
inline SolveResult solvePowerDominatingSet(PdsState& state, bool output, double timeLimit, F model = modelJovanovicExpanded) {
auto mip = model(state);
auto result = solveMIP(mip, output, timeLimit);
if (result.state != SolveState::Infeasible) {
applySolution(state, mip);
}
return result;
}
//inline SolveState solve_pds(PdsState& state, bool output = false, double timeLimit = TIME_LIMIT) {
// return solve_pds(state, output, timeLimit, modelJovanovicExpanded);
//}
} //namespace pds
#endif //PDS_GUROBI_SOLVE_HPP

Computing file changes ...