# Path: stationary/processes/incentives.py
# def constant_fitness(c):
#     def f(pop):
# def linear_fitness_landscape(m, self_interaction=True, normalize=False):
#     def f(pop):
# def rock_paper_scissors(a=1, b=1):
# def replicator(fitness, q=1, **kwargs):
#         def f(x):
#     def g(x):
# def logit(fitness, beta=1., q=0.):
#         def f(x):
#     def g(x):
# def fermi(fitness, beta=1., q=1.):
# def logit2(fitness, beta=1., **kwargs):
#     def g(x):
# def simple_best_reply(fitness):
#     def g(x):
#         N = sum(pop)
# 
# Path: stationary/processes/incentive_process.py
# def is_valid_state(state, lower, upper):
# def multivariate_transitions(N, incentive, num_types=3, mu=0.001,
#                              no_boundary=False):
# def multivariate_transitions_gen(N, incentive, num_types=3, mu=0.001,
#                                  no_boundary=False):
# def log_multivariate_transitions(N, logincentive, num_types=3, mu=0.001,
#                                  no_boundary=False):
# def compute_edges(N=30, num_types=None, m=None, incentive_func=logit, beta=1.,
#                   q=1., mu=None):
# def k_fold_incentive_transitions(N, incentive, num_types, mu=None, k=None):
# def neutral_stationary(N, alpha, n=3, logspace=False):
# def log_neutral_stationary(N, alpha, n=3):


import math
import os
import pickle
import sys
import matplotlib
import matplotlib.gridspec as gridspec
import numpy as np
import scipy.misc
import ternary
import stationary
from matplotlib import pyplot as plt
from stationary.processes import incentives, incentive_process
"""Figures for the publication
"Entropic Equilibria Selection of Stationary Extrema in Finite Populations"
"""

from __future__ import print_function




## Global Font config for plots ###
font = {'size': 14}
matplotlib.rc('font', **font)


def compute_entropy_rate(N=30, n=2, m=None, incentive_func=None, beta=1.,
                         mu=None, exact=False, lim=1e-13, logspace=False):
    if not m:
        m = np.ones((n, n))
    if not incentive_func:
        incentive_func = incentives.fermi
    if not mu:
        # mu = (n-1.)/n * 1./(N+1)
        mu = 1. / N


# Path: stationary/processes/incentives.py
# def constant_fitness(c):
#     def f(pop):
# def linear_fitness_landscape(m, self_interaction=True, normalize=False):
#     def f(pop):
# def rock_paper_scissors(a=1, b=1):
# def replicator(fitness, q=1, **kwargs):
#         def f(x):
#     def g(x):
# def logit(fitness, beta=1., q=0.):
#         def f(x):
#     def g(x):
# def fermi(fitness, beta=1., q=1.):
# def logit2(fitness, beta=1., **kwargs):
#     def g(x):
# def simple_best_reply(fitness):
#     def g(x):
#         N = sum(pop)
# 
# Path: stationary/processes/incentive_process.py
# def is_valid_state(state, lower, upper):
# def multivariate_transitions(N, incentive, num_types=3, mu=0.001,
#                              no_boundary=False):
# def multivariate_transitions_gen(N, incentive, num_types=3, mu=0.001,
#                                  no_boundary=False):
# def log_multivariate_transitions(N, logincentive, num_types=3, mu=0.001,
#                                  no_boundary=False):
# def compute_edges(N=30, num_types=None, m=None, incentive_func=logit, beta=1.,
#                   q=1., mu=None):
# def k_fold_incentive_transitions(N, incentive, num_types, mu=None, k=None):
# def neutral_stationary(N, alpha, n=3, logspace=False):
# def log_neutral_stationary(N, alpha, n=3):


# Path: examples/entropic_equilibria_plots.py
import math
import os
import pickle
import sys
import matplotlib
import matplotlib.gridspec as gridspec
import numpy as np
import scipy.misc
import ternary
import stationary
from matplotlib import pyplot as plt
from stationary.processes import incentives, incentive_process

"""Figures for the publication
"Entropic Equilibria Selection of Stationary Extrema in Finite Populations"
"""

from __future__ import print_function




## Global Font config for plots ###
font = {'size': 14}
matplotlib.rc('font', **font)


def compute_entropy_rate(N=30, n=2, m=None, incentive_func=None, beta=1.,
                         mu=None, exact=False, lim=1e-13, logspace=False):
    if not m:
        m = np.ones((n, n))
    if not incentive_func:
        incentive_func = incentives.fermi
    if not mu:
        # mu = (n-1.)/n * 1./(N+1)
        mu = 1. / N


    fitness_landscape = incentives.linear_fitness_landscape(m)