2 #include <boost/log/core.hpp> 3 #include <boost/log/expressions.hpp> 4 #include <boost/log/trivial.hpp> 5 #include <gurobi_c++.h> 10 void addLeader(std::shared_ptr<Game::NashGame> N,
const unsigned int i) {
12 ends[i] = N->getNprimals() + N->getNleaderVars();
39 throw std::string(
"Invalid make_obj_leader");
46 arma::sp_mat Q(2, 2), C(2, 1), A(2, 1), B(2, 2);
47 arma::vec c(2, arma::fill::zeros);
48 arma::vec b(2, arma::fill::zeros);
62 auto foll = std::make_shared<Game::QP_Param>(Q, C, A, B, c, b,
env);
65 arma::sp_mat MC(0, 3);
66 arma::vec MCRHS(0, arma::fill::zeros);
68 arma::sp_mat LeadCons(1, 3);
75 auto N = std::make_shared<Game::NashGame>(
76 env, std::vector<std::shared_ptr<Game::QP_Param>>{foll}, MC, MCRHS, 1,
83 arma::sp_mat Q(2, 2), C(2, 1), A(2, 1), B(2, 2);
84 arma::vec c(2, arma::fill::zeros);
85 arma::vec b(2, arma::fill::zeros);
102 auto foll = std::make_shared<Game::QP_Param>(Q, C, A, B, c, b,
env);
105 arma::sp_mat MC(0, 3);
106 arma::vec MCRHS(0, arma::fill::zeros);
108 arma::sp_mat LeadCons(2, 3);
109 arma::vec LeadRHS(2);
120 auto N = std::make_shared<Game::NashGame>(
121 env, std::vector<std::shared_ptr<Game::QP_Param>>{foll}, MC, MCRHS, 1,
128 boost::log::core::get()->set_filter(boost::log::trivial::severity >=
129 boost::log::trivial::warning);
143 }
catch (std::string &s) {
144 std::cerr <<
"Error caught: " << s <<
'\n';
152 std::cout <<
"\nUV LEADER\n";
157 std::for_each(std::begin(uv_strats), std::end(uv_strats),
158 [&epec](
const unsigned int i) {
166 std::cout <<
"\nXY LEADER\n";
171 std::for_each(std::begin(xy_strats), std::end(xy_strats),
172 [&epec](
const unsigned int i) {
void updateLocs() override
std::shared_ptr< Game::NashGame > uv_leader(GRBEnv *env)
double getVal_Probab(const unsigned int i, const unsigned int k) const
void finalize()
Finalizes the creation of a Game::EPEC object.
Class to handle a Nash game between leaders of Stackelberg games.
double getVal_LeadLeadPoly(const unsigned int i, const unsigned int j, const unsigned int k, const double tol=1e-5) const
std::vector< unsigned int > convexHullVariables
void addLeader(std::shared_ptr< Game::NashGame > N, const unsigned int i)
struct to handle the objective params of MP_Param/QP_Param
void make_obj_leader(const unsigned int i, Game::QP_objective &QP_obj) override
Can be instantiated by a derived class only!
std::vector< const unsigned int * > LocEnds
std::vector< std::shared_ptr< Game::NashGame > > countries_LL
double getVal_LeadFoll(const unsigned int i, const unsigned int j) const
std::vector< unsigned int > mixedStratPoly(const unsigned int i, const double tol=1e-5) const
std::shared_ptr< Game::NashGame > xy_leader(GRBEnv *env)
double getVal_LeadFollPoly(const unsigned int i, const unsigned int j, const unsigned int k, const double tol=1e-5) const
double getVal_LeadLead(const unsigned int i, const unsigned int j) const
void setAlgorithm(Game::EPECalgorithm algorithm)