Skip to content
Merged
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ core_SOURCES = \
src/core/core.h \
src/core/util.h \
src/core/array.h \
src/core/list.h \
src/core/vector.h \
src/core/recarray.h \
src/core/matrix.h \
Expand Down
1 change: 0 additions & 1 deletion src/core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include "util.h"
#include "array.h"
#include "list.h"
#include "recarray.h"
#include "vector.h"
#include "matrix.h"
Expand Down
144 changes: 0 additions & 144 deletions src/core/list.h

This file was deleted.

37 changes: 37 additions & 0 deletions src/core/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,43 @@ template <class Key, class T> bool contains(const std::map<Key, T> &map, const K
return map.find(key) != map.end();
}

template <class C> class EnumerateView {
public:
explicit EnumerateView(C &p_range) : m_range(p_range) {}

class iterator {
public:
using base_iterator = decltype(std::begin(std::declval<C &>()));

iterator(const std::size_t p_index, base_iterator p_current)
: m_index(p_index), m_current(p_current)
{
}

iterator &operator++()
{
++m_index;
++m_current;
return *this;
}

bool operator!=(const iterator &p_other) const { return m_current != p_other.m_current; }
auto operator*() const { return std::tie(m_index, *m_current); }

private:
std::size_t m_index;
base_iterator m_current;
};

iterator begin() { return iterator{0, std::begin(m_range)}; }
iterator end() { return iterator{0, std::end(m_range)}; }

private:
C &m_range;
};

template <class C> auto enumerate(C &p_range) { return EnumerateView<C>(p_range); }

/// @brief A container adaptor which returns only the elements matching the predicate
/// This is intended to look forward to C++20-style ranges
template <typename Container, typename Pred> class filter_if {
Expand Down
38 changes: 0 additions & 38 deletions src/gui/gamedoc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,44 +338,6 @@ void GameDocument::SetProfileList(int p_index)
UpdateViews(GBT_DOC_MODIFIED_VIEWS);
}

/*
void GameDocument::AddProfiles(const List<MixedBehavProfile<double> >
&p_profiles)
{
for (int i = 1; i <= p_profiles.Length(); i++) {
m_profiles[m_currentProfileList].Append(p_profiles[i]);
}

m_profiles[m_currentProfileList].SetCurrent(m_profiles[m_currentProfileList].NumProfiles());
UpdateViews(GBT_DOC_MODIFIED_VIEWS);
}

void GameDocument::AddProfile(const MixedBehavProfile<double> &p_profile)
{
m_profiles[m_currentProfileList].Append(p_profile);
m_profiles[m_currentProfileList].SetCurrent(m_profiles[m_currentProfileList].NumProfiles());
UpdateViews(GBT_DOC_MODIFIED_VIEWS);
}

void GameDocument::AddProfiles(const List<MixedStrategyProfile<double> >
&p_profiles)
{
for (int i = 1; i <= p_profiles.Length(); i++) {
m_profiles[m_currentProfileList].Append(p_profiles[i]);
}

m_profiles[m_currentProfileList].SetCurrent(m_profiles[m_currentProfileList].NumProfiles());
UpdateViews(GBT_DOC_MODIFIED_VIEWS);
}

void GameDocument::AddProfile(const MixedStrategyProfile<double> &p_profile)
{
m_profiles[m_currentProfileList].Append(p_profile);
m_profiles[m_currentProfileList].SetCurrent(m_profiles[m_currentProfileList].NumProfiles());
UpdateViews(GBT_DOC_MODIFIED_VIEWS);
}
*/

void GameDocument::SetStrategyElimStrength(bool p_strict)
{
m_stratSupports.SetStrict(p_strict);
Expand Down
7 changes: 0 additions & 7 deletions src/gui/gamedoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,6 @@ class GameDocument {
return (m_profiles.size() == 0) ? 0 : GetProfiles().GetCurrent();
}
void SetCurrentProfile(int p_profile);
/*
void AddProfiles(const List<MixedBehavProfile<double> > &);
void AddProfile(const MixedBehavProfile<double> &);
void AddProfiles(const List<MixedStrategyProfile<double> > &);
void AddProfile(const MixedStrategyProfile<double> &);
*/
//@}

//!
//! @name Handling of behavior supports
Expand Down
18 changes: 6 additions & 12 deletions src/pygambit/gambit.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ cdef extern from "core/array.h":
iterator end() except +


cdef extern from "core/list.h":
cdef cppclass c_List "List"[T]:
T & getitem "operator[]"(int) except +
int size() except +
void push_back(T) except +

cdef extern from "games/game.h":
cdef cppclass c_GameRep "GameRep"
cdef cppclass c_GameStrategyRep "GameStrategyRep"
Expand Down Expand Up @@ -463,22 +457,22 @@ cdef extern from "util.h":
c_GameAction, c_Rational) except +

shared_ptr[c_MixedStrategyProfile[double]] copyitem_list_mspd "sharedcopyitem"(
c_List[c_MixedStrategyProfile[double]], int
stdlist[c_MixedStrategyProfile[double]], int
) except +
shared_ptr[c_MixedStrategyProfile[c_Rational]] copyitem_list_mspr "sharedcopyitem"(
c_List[c_MixedStrategyProfile[c_Rational]], int
stdlist[c_MixedStrategyProfile[c_Rational]], int
) except +
shared_ptr[c_MixedBehaviorProfile[double]] copyitem_list_mbpd "sharedcopyitem"(
c_List[c_MixedBehaviorProfile[double]], int
stdlist[c_MixedBehaviorProfile[double]], int
) except +
shared_ptr[c_MixedBehaviorProfile[c_Rational]] copyitem_list_mbpr "sharedcopyitem"(
c_List[c_MixedBehaviorProfile[c_Rational]], int
stdlist[c_MixedBehaviorProfile[c_Rational]], int
) except +
shared_ptr[c_LogitQREMixedStrategyProfile] copyitem_list_qrem "sharedcopyitem"(
c_List[c_LogitQREMixedStrategyProfile], int
stdlist[c_LogitQREMixedStrategyProfile], int
) except +
shared_ptr[c_LogitQREMixedBehaviorProfile] copyitem_list_qreb "sharedcopyitem"(
c_List[c_LogitQREMixedBehaviorProfile], int
stdlist[c_LogitQREMixedBehaviorProfile], int
) except +


Expand Down
13 changes: 6 additions & 7 deletions src/solvers/enummixed/clique.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,9 @@ class CliqueEnumerator {
public:
class Edge {
public:
int node1;
int node2;
int nextedge;
Edge() = default;
int node1, node2, nextedge{};

explicit Edge(const int n1, const int n2) : node1(n1), node2(n2) {}
~Edge() = default;
bool operator==(const Edge &y) const { return (node1 == y.node1 && node2 == y.node2); }
bool operator!=(const Edge &y) const { return !(*this == y); }
Expand All @@ -211,13 +210,13 @@ class CliqueEnumerator {
CliqueEnumerator(Array<Edge> &, int, int);
~CliqueEnumerator() = default;

const List<Array<int>> &GetCliques1() const { return m_cliques1; }
const List<Array<int>> &GetCliques2() const { return m_cliques2; }
const Array<Array<int>> &GetCliques1() const { return m_cliques1; }
const Array<Array<int>> &GetCliques2() const { return m_cliques2; }

private:
Array<int> firstedge;
int maxinp1, maxinp2;
List<Array<int>> m_cliques1, m_cliques2;
Array<Array<int>> m_cliques1, m_cliques2;

void candtry1(int stk[], // stack
bool connected[MAXM][MAXN],
Expand Down
21 changes: 9 additions & 12 deletions src/solvers/enummixed/enummixed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bool EqZero(const double &x)
bool EqZero(const Rational &x) { return x == Rational(0); }

template <class T>
List<List<MixedStrategyProfile<T>>> EnumMixedStrategySolution<T>::GetCliques() const
Array<Array<MixedStrategyProfile<T>>> EnumMixedStrategySolution<T>::GetCliques() const
{
if (m_cliques1.empty()) {
// Cliques are generated on demand
Expand All @@ -47,20 +47,19 @@ List<List<MixedStrategyProfile<T>>> EnumMixedStrategySolution<T>::GetCliques() c
throw DimensionException();
}

Array<CliqueEnumerator::Edge> edgelist(n);
for (size_t i = 1; i <= n; i++) {
edgelist[i].node1 = m_node1[i];
edgelist[i].node2 = m_node2[i];
}
Array<CliqueEnumerator::Edge> edgelist;
edgelist.reserve(n);
std::transform(m_node1.begin(), m_node1.end(), m_node2.begin(), std::back_inserter(edgelist),
[](const int a, const int b) { return CliqueEnumerator::Edge(a, b); });

const CliqueEnumerator clique(edgelist, m_v2 + 1, m_v1 + 1);
m_cliques1 = clique.GetCliques1();
m_cliques2 = clique.GetCliques2();
}

List<List<MixedStrategyProfile<T>>> solution;
Array<Array<MixedStrategyProfile<T>>> solution;
for (size_t cl = 1; cl <= m_cliques1.size(); cl++) {
solution.push_back(List<MixedStrategyProfile<T>>());
solution.push_back(Array<MixedStrategyProfile<T>>());
for (size_t i = 1; i <= m_cliques1[cl].size(); i++) {
for (size_t j = 1; j <= m_cliques2[cl].size(); j++) {
MixedStrategyProfile<T> profile(m_game->NewMixedStrategyProfile(static_cast<T>(0)));
Expand Down Expand Up @@ -138,10 +137,8 @@ EnumMixedStrategySolveDetailed(const Game &p_game, StrategyCallbackType<T> p_onE

Array<int> vert1id(solution->m_v1);
Array<int> vert2id(solution->m_v2);
for (size_t i = 1; i <= vert1id.size(); vert1id[i++] = 0)
;
for (size_t i = 1; i <= vert2id.size(); vert2id[i++] = 0)
;
std::fill(vert1id.begin(), vert1id.end(), 0);
std::fill(vert2id.begin(), vert2id.end(), 0);

int id1 = 0, id2 = 0;

Expand Down
Loading