ssriram1992 / EPECsolve

Code to compute mixed-equilibrium in linear EPECs
https://ssriram1992.github.io/EPECsolve/html/index.html
GNU General Public License v3.0
6 stars 2 forks source link

[Issue with MNE] Completely wrong answers! #16

Closed ssriram1992 closed 4 years ago

ssriram1992 commented 4 years ago

The following code, which has essentially 0 cost for all producers and 0 tax, i.e., tax forced to be zero should make all producers produce a high quantity, given the domestic price is high. But something super weird seems to happen.

#include "models.h"
#include <boost/log/core.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/trivial.hpp>
#include <string>

Models::EPECInstance ChileArgentinaInstance() {
  Models::FollPar Arg, Chi;
  // steam groupped into geotherm

  Chi.names = {"Coal", "Wind", "Gas", "Hydro", "Solar", "Diesel"};
  Arg.names = {"Wind", "Gas", "Hydro", "Solar", "Diesel"};

  // In million dollars per terawatt-hour of energy

  Models::FollPar Chi_Main{
      {0, 0, 0},            // quad
      {0, 0, 0},             // lin
      {27, 23, 22},             // cap
      {200, 110, 0},            // emm
      {50, 100, 20},            // tax
      {"Coal", "Gas", "Hydro"}, // name
  };

  Models::FollPar Arg_Main{
      {0.0001, 0},         // quad
      {0, 0},         // lin
      {93, 37},         // cap
      {110, 0},         // emm
      {119, 20},        // tax
      {"Gas", "Hydro"}, // name
  };

  Chi = Chi_Main;
  Arg = Arg_Main;

  Chi.tax_caps = Chi.costs_lin;
  Arg.tax_caps = Arg.costs_lin;

  Models::LeadAllPar Chile(Chi.capacities.size(), "Chile", Chi, {500, 5.77},
                           {-1, -1, 140, false, 0});
  Models::LeadAllPar Argentina(Arg.capacities.size(), "Argentina", Arg,
                               {2400, 14.43}, {-1, -1, 8000, false, 0});
  arma::sp_mat TrCo2(2, 2);
  TrCo2(1, 0) = 1;
  TrCo2(0, 1) = 1;
  Models::EPECInstance Instance2({Argentina, Chile}, TrCo2);
  Instance2.save("dat/ChileArgentina2_Q");
  return Instance2;
}

void solve(Models::EPECInstance instance) {
  GRBEnv env;
  Models::EPEC epec(&env);
  const unsigned int nCountr = instance.Countries.size();
  for (unsigned int i = 0; i < nCountr; i++)
    epec.addCountry(instance.Countries.at(i));
  epec.addTranspCosts(instance.TransportationCosts);
  epec.finalize();
  epec.setAlgorithm(Game::EPECalgorithm::fullEnumeration);
  epec.setAggressiveness(1);
  epec.setAddPolyMethod(Game::EPECAddPolyMethod::reverse_sequential);
  std::cout << "Starting to solve...\n";
  epec.setNumThreads(4);
  epec.findNashEq();
  epec.writeSolution(2, "dat/ChileArgentinaCarb");
}

int main() {
  boost::log::core::get()->set_filter(boost::log::trivial::severity >=
                                      boost::log::trivial::info);
  solve(ChileArgentinaInstance());
  return 0;
}
ssriram1992 commented 4 years ago

Answers we get are Price in Argentina: 2048 Gas production: 79 (cap 93; marginal cost: 0.01) Hydro production: 32 (cap 37; marginal cost: 0.00) Exports: 86.66 at export price 33.40

Price in Chile: 0 (Cap: 27) Coal production: 0 (Cap: 23) Gas production: 0 (Cap: 22) Hydro production: 0 Import: 86.66

Weird thing - both countries both export and import from each other for some weird reason.

Price constraint P=a-bQ is not satisfied by Chile. For Chile a=140, Q=0 So, we should have P=140 but for some reason P=0.