Exemple #1
0
    f3 = ((y[0]**3) * A[2][0]) + (3* y[0]* y[0] * y[1] * A[2][1]) + (3* y[0]* y[0] * y[2] * A[2][2])+ (3* y[0]* y[1] * y[1] * A[2][3])+ (6* y[0]* y[1] * y[2] * A[2][4])+ (3* y[0]* y[2] * y[2] * A[2][5])+ ( (y[1]**3) * A[2][6])+ (3* y[1]* y[1] * y[2] * A[2][7])+ (3* y[1]* y[2] * y[2] * A[2][8])+ ( (y[2]**3) * A[2][9])

    phi = (y[0] * f1) + (y[1] * f2) + (y[2] *f3)

    xx1 = y[0] * ( f1-phi)
    xx2 = y[1] * ( f2-phi)
    xx3 = y[2] * ( f3-phi)

    xx = np.array([xx1])

    yy = np.array([xx2] )

    zz = 1 - ( xx+yy)

    diff =  np.concatenate([xx,yy,zz])
    return xx1,xx2,xx3
    
    

t = np.arange(0,60,0.01)

#initialize simplex_dynamics object with function
dynamics1=egtsimplex.simplex_dynamics(f1)


#plot the simplex dynamics
fig,ax=plt.subplots()
dynamics1.plot_simplex(ax)
plt.show()    

Exemple #2
0
    return z


delta_list = []
for i in range(len(alpha_vec)):
    av_in = alpha_vec[i]
    lerm = loss_list[i][0]
    ldro = loss_list[i][1]
    erm_delta = loss_mapper(av_in, lerm) - av_in
    dro_delta = [loss_mapper(av_in, lsub) - av_in for lsub in ldro]
    delta_list.append([erm_delta, dro_delta])

lvec = np.arange(0.0, 0.12, 0.005)
#cm = 'viridis_r'
cm = 'Blues'
dynamics = egtsimplex.simplex_dynamics(
    f_interp_fact(alpha_vec, zip(*[delt[0] for delt in delta_list])))
fig, ax = plt.subplots()
dynamics.plot_simplex(ax, levels=lvec, cmap=cm)
plt.tight_layout()
plt.savefig('test_vec_erm.png')

dynamics = egtsimplex.simplex_dynamics(
    f_interp_fact(alpha_vec, zip(*[delt[1][1] for delt in delta_list])))
fig, ax = plt.subplots()
dynamics.plot_simplex(ax, levels=lvec, cmap=cm)
plt.tight_layout()
plt.savefig('test_vec_dro1.png')

dynamics = egtsimplex.simplex_dynamics(
    f_interp_fact(alpha_vec, zip(*[delt[1][2] for delt in delta_list])))
fig, ax = plt.subplots()
Exemple #3
0
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.
#################
import matplotlib.pyplot as plt
import numpy as np
import egtsimplex


#define function of x=[x0,x1,x2] and t to plot dynamics on simplex
def f(x, t):
    A = np.array([[0, 1, -1], [-1, 0, 1], [1, -1, 0]])
    phi = (x.dot(A.dot(x)))
    x0dot = x[0] * (A.dot(x)[0] - phi)
    x1dot = x[1] * (A.dot(x)[1] - phi)
    x2dot = x[2] * (A.dot(x)[2] - phi)
    return [x0dot, x1dot, x2dot]


#initialize simplex_dynamics object with function
dynamics = egtsimplex.simplex_dynamics(f)

#plot the simplex dynamics
fig, ax = plt.subplots()
dynamics.plot_simplex(ax)
plt.show()
Exemple #4
0
def calc_new_strat(x, table):
    return LEARNING_RATE * calc_xdot(x, table)


payoffs = pd.read_pickle('dr.pik')


def f(x, t):
    A = np.array([[0, 1, -1], [-1, 0, 1], [1, -1, 0]])
    phi = (x.dot(A.dot(x)))
    x0dot = x[0] * (A.dot(x)[0] - phi)
    x1dot = x[1] * (A.dot(x)[1] - phi)
    x2dot = x[2] * (A.dot(x)[2] - phi)
    return [x0dot, x1dot, x2dot]


dynamics = egtsimplex.simplex_dynamics(
    lambda probs, t: calc_new_strat(probs, payoffs))
# dynamics=egtsimplex.simplex_dynamics(f)
import pdb
pdb.set_trace()

#initialize simplex_dynamics object with function
# dynamics=egtsimplex.simplex_dynamics(f)

#plot the simplex dynamics
fig, ax = plt.subplots()
dynamics.plot_simplex(ax, typelabels=['DR100', 'DR30', 'DR10'])
plt.show()