Skip to content

Commit f3217a6

Browse files
authored
Remove C++ subgame-perfect equilibrium solver (#641)
* Remove C++ solve-by-subgames implementation. This removes the subgame-perfect equilibrium solver in C++ and from the associated command-line tools for `enumpure`, `lp`, and `lcp`. This will be replace in due course with a more flexible and customisable functionality. Closes #637.
1 parent 010baa6 commit f3217a6

File tree

19 files changed

+140
-536
lines changed

19 files changed

+140
-536
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
### Removed
1818
- Eliminating dominated actions has been removed from the GUI as it was implementing a non-standard
1919
formulation of dominance. (#612)
20+
- The C++ method for computing subgame perfect equilibria with selected methods has been removed
21+
(and as a result from the `enumpure`, `lp`, and `lcp` command-line tools); this will be replaced
22+
with new and more customisable approaches. (#639)
2023

2124
## [16.4.1] - unreleased
2225

Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ game_SOURCES = \
309309
src/games/stratpure.cc \
310310
src/games/stratpure.h \
311311
src/games/stratmixed.h \
312-
src/games/nash.cc \
313312
src/games/file.cc \
314313
src/games/writer.cc \
315314
src/games/writer.h \

doc/tools.enumpure.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ pure-strategy Nash equilibria.
4343
extensive games, as strategic games have only one information set
4444
per player.
4545

46-
.. cmdoption:: -P
47-
48-
By default, the program computes all pure-strategy Nash
49-
equilibria in an extensive game. This switch instructs the program to
50-
find only pure-strategy Nash equilibria which are subgame perfect.
51-
(This has no effect for strategic games, since there are no proper
52-
subgames of a strategic game.)
53-
5446
.. cmdoption:: -h
5547

5648
Prints a help message listing the available options.

doc/tools.lcp.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,6 @@ game.
5151
causes the program to output greater detail on each equilbrium
5252
profile computed.
5353

54-
.. cmdoption:: -P
55-
56-
By default, the program computes Nash equilibria in an extensive
57-
game. This switch instructs the program to find only equilibria
58-
which are subgame perfect. (This has no effect for strategic
59-
games, since there are no proper subgames of a strategic game.)
60-
6154
.. cmdoption:: -e EQA
6255

6356
By default, the program will find all equilibria accessible from

doc/tools.lp.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ points of that set.
4444
causes the program to output greater detail on each equilbrium
4545
profile computed.
4646

47-
.. cmdoption:: -P
48-
49-
By default, the program computes Nash equilibria in an extensive
50-
game. This switch instructs the program to find only equilibria
51-
which are subgame perfect. (This has no effect for strategic
52-
games, since there are no proper subgames of a strategic game.)
53-
5447
.. cmdoption:: -h
5548

5649
Prints a help message listing the available options.

src/games/nash.cc

Lines changed: 0 additions & 204 deletions
This file was deleted.

src/games/nash.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ ToMixedBehaviorProfile(const std::list<MixedStrategyProfile<T>> &p_list)
6060
template <class T>
6161
using BehaviorSolverType = std::function<std::list<MixedBehaviorProfile<T>>(const Game &)>;
6262

63-
template <class T>
64-
std::list<MixedBehaviorProfile<T>> SolveBySubgames(const Game &, BehaviorSolverType<T> p_solver,
65-
BehaviorCallbackType<T> p_onEquilibrium);
66-
6763
//
6864
// Exception raised when maximum number of equilibria to compute
6965
// has been reached. A convenience for unraveling a potentially

src/tools/convert/convert.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222

2323
#include <iostream>
2424
#include <fstream>
25-
#include <cstdlib>
2625
#include <getopt.h>
2726

2827
#include "gambit.h"
2928
#include "games/writer.h"
3029

30+
using namespace Gambit;
31+
3132
void PrintBanner(std::ostream &p_stream)
3233
{
3334
p_stream << "Convert games among various file formats\n";
@@ -79,7 +80,7 @@ int main(int argc, char *argv[])
7980
break;
8081
case '?':
8182
if (isprint(optopt)) {
82-
std::cerr << argv[0] << ": Unknown option `-" << ((char)optopt) << "'.\n";
83+
std::cerr << argv[0] << ": Unknown option `-" << static_cast<char>(optopt) << "'.\n";
8384
}
8485
else {
8586
std::cerr << argv[0] << ": Unknown option character `\\x" << optopt << "`.\n";
@@ -122,7 +123,7 @@ int main(int argc, char *argv[])
122123
}
123124

124125
try {
125-
const Gambit::Game game = Gambit::ReadGame(*input_stream);
126+
const Game game = ReadGame(*input_stream);
126127

127128
if (rowPlayer < 1 || rowPlayer > static_cast<int>(game->NumPlayers())) {
128129
std::cerr << argv[0] << ": Player " << rowPlayer << " does not exist.\n";

src/tools/enummixed/enummixed.cc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2121
//
2222

23-
#include <cstdlib>
2423
#include <getopt.h>
2524
#include <iostream>
2625
#include <fstream>
@@ -34,7 +33,7 @@ using namespace Gambit::Nash;
3433

3534
template <class T>
3635
void PrintCliques(const List<List<MixedStrategyProfile<T>>> &p_cliques,
37-
std::shared_ptr<StrategyProfileRenderer<T>> p_renderer)
36+
std::shared_ptr<MixedProfileRenderer<T>> p_renderer)
3837
{
3938
for (size_t cl = 1; cl <= p_cliques.size(); cl++) {
4039
for (size_t i = 1; i <= p_cliques[cl].size(); i++) {
@@ -75,7 +74,7 @@ int main(int argc, char *argv[])
7574
int numDecimals = 6;
7675

7776
int long_opt_index = 0;
78-
struct option long_options[] = {
77+
option long_options[] = {
7978
{"help", 0, nullptr, 'h'}, {"version", 0, nullptr, 'v'}, {nullptr, 0, nullptr, 0}};
8079
while ((c = getopt_long(argc, argv, "d:vhqcS", long_options, &long_opt_index)) != -1) {
8180
switch (c) {
@@ -99,7 +98,7 @@ int main(int argc, char *argv[])
9998
break;
10099
case '?':
101100
if (isprint(optopt)) {
102-
std::cerr << argv[0] << ": Unknown option `-" << ((char)optopt) << "'.\n";
101+
std::cerr << argv[0] << ": Unknown option `-" << static_cast<char>(optopt) << "'.\n";
103102
}
104103
else {
105104
std::cerr << argv[0] << ": Unknown option character `\\x" << optopt << "`.\n";
@@ -130,8 +129,7 @@ int main(int argc, char *argv[])
130129
try {
131130
const Game game = ReadGame(*input_stream);
132131
if (useFloat) {
133-
std::shared_ptr<StrategyProfileRenderer<double>> renderer =
134-
std::make_shared<MixedStrategyCSVRenderer<double>>(std::cout, numDecimals);
132+
auto renderer = MakeMixedStrategyProfileRenderer<double>(std::cout, numDecimals, false);
135133
auto solution = EnumMixedStrategySolveDetailed<double>(
136134
game, [&](const MixedStrategyProfile<double> &p, const std::string &label) {
137135
renderer->Render(p, label);
@@ -141,8 +139,7 @@ int main(int argc, char *argv[])
141139
}
142140
}
143141
else {
144-
std::shared_ptr<StrategyProfileRenderer<Rational>> renderer(
145-
new MixedStrategyCSVRenderer<Rational>(std::cout));
142+
auto renderer = MakeMixedStrategyProfileRenderer<Rational>(std::cout, numDecimals, false);
146143
auto solution = EnumMixedStrategySolveDetailed<Rational>(
147144
game, [&](const MixedStrategyProfile<Rational> &p, const std::string &label) {
148145
renderer->Render(p, label);

0 commit comments

Comments
 (0)