def draw(): data=md.loadData('result.tl') for n,(k,v) in enumerate(data.iteritems()): mat=v[2]['matrix'] path='fig/fig_%s'%k os.mkdir(path) for i in range(0,len(mat),1): drawHeatMap(mat[i],os.path.join(path,'%d.png'%i),3*k,i*div[n])
def draw(): data = md.loadData('result.tl') for n, (k, v) in enumerate(data.iteritems()): mat = v[2]['matrix'] path = 'fig/fig_%s' % k os.mkdir(path) for i in range(0, len(mat), 1): drawHeatMap(mat[i], os.path.join(path, '%d.png' % i), 3 * k, i * div[n])
def draw1(): data=md.loadData('result1.tl') n=4 k=25 v=data[k] mat=v[3]['matrix'] path='fig/fig_%s'%k if not os.path.exists(path): os.mkdir(path) for i in range(0,len(mat),2): drawHeatMap(mat[i],os.path.join(path,'%d.png'%int(i/2)),3*k,i*div[n])
def draw1(): data = md.loadData('result1.tl') n = 4 k = 25 v = data[k] mat = v[3]['matrix'] path = 'fig/fig_%s' % k if not os.path.exists(path): os.mkdir(path) for i in range(0, len(mat), 2): drawHeatMap(mat[i], os.path.join(path, '%d.png' % int(i / 2)), 3 * k, i * div[n])
def draw(): global SL data=md.loadData('result.tl') for k,v in data.iteritems(): SL=14.0/k L=[] for i in range(k-1): L.append(-7+(i+1)*SL-0.01) X1=np.insert(X,0,L) X1.sort() plt.figure(k) plt.plot(X,Y,'b.',alpha=0.6,label="measure point") plt.plot(X1,map(realLineFunc(v[0]['param']),X1),c="red",lw=2,ls="-",alpha=0.7,label="M1") plt.plot(X1,map(realLineFunc(v[1]['param']),X1),c="blue",lw=2,ls="-",alpha=0.7,label="M2") plt.plot(X1,map(realLineFunc(v[2]['param']),X1),c="black",lw=2,ls="--",alpha=0.7,label="M3") plt.plot(X1,map(lambda x:10*math.sin(0.6*x),X1),c="cyan",lw=2,ls="-",alpha=0.7,label="real function") plt.legend(loc='best') plt.title("fitting interval sin curve with quadratic curve by %s partition"%k) plt.xlabel('x') plt.ylabel('y') plt.savefig('img/img_%s.pdf'%k)
__author__ = "luzhijun" ''' cma restart test ''' import cma import math import numpy as np import matplotlib.pyplot as plt from multiprocessing import Pool import makeData as md import time plt.rc('figure', figsize=(16, 9)) PI = math.pi E = math.exp data = md.loadData('data.tl') X = data[0] Y = data[1] RANGE = max(Y) - min(Y) PN = 300 ALPHA = 0.01 BETA = PI / 18.0 PARTITION = 5 DIM = 3 * PARTITION SPN = int(PN / PARTITION) SL = 14.0 / PARTITION L = []
sys.path.append('..') import makeData shuffling = True scaling = True max_cmd_vel_linear_x = 0.5 max_cmd_vel_angular_z = 1 bias_cmd_vel_angular = 0 max_iteration = 10001 disp_epoch = 50 save_epoch = 2000 #imgwidth=80; #imgheight=60; # first make data inputs, labels = makeData.loadData('../data/data518/', resize=None) batchsize = 16 Ndata = len(labels) vmode = 0 #0 for speed, 1 for angular velocity images = [] cmdvels = [] randomidx = range(Ndata) random.shuffle(randomidx) for i in range(Ndata): images.append(inputs[randomidx[i]]) cmdvels.append(labels[randomidx[i]])
#!usr/bin/env python #encoding: utf-8 __author__="luzhijun" ''' make linear data sets ''' import numpy as np import math import makeData as md import matplotlib.pyplot as plt plt.rc('figure', figsize=(16, 9)) dataSet=md.loadData('data.tl') X=dataSet[0] Y=dataSet[1] def realLineFunc(param): def f(x): i=int(math.floor((x+7)/SL)) return np.poly1d(param[3*i:3*(i+1)])(x) return f def draw(): global SL data=md.loadData('result.tl') for k,v in data.iteritems(): SL=14.0/k L=[]
__author__="luzhijun" ''' cma restart test ''' import cma import math import numpy as np import matplotlib.pyplot as plt from multiprocessing import Pool import makeData as md import time plt.rc('figure', figsize=(16, 9)) PI=math.pi E=math.exp data=md.loadData('data.tl') X=data[0] Y=data[1] RANGE=max(Y)-min(Y) PN=300 ALPHA=0.01 BETA=PI/18.0 PARTITION=5 DIM=3*PARTITION SPN=int(PN/PARTITION) SL=14.0/PARTITION L=[]