Example #1
0
File: gui.py Project: gic888/MIEN
def loadArrayStore(gui):
	fn=''
	try:
		file=gui.ga.attrib('File')
		dp, fn=os.path.split(file)
		if not dp:
			file=self.document.fileinformation["filename"]
			dp=os.path.split(file)[0]
	except:
		dp=os.getcwd()
	dlg=wx.FileDialog(gui, message="Select arraystore file", defaultDir=dp, defaultFile=fn, style=wx.OPEN)
	dlg.CenterOnParent()
	if dlg.ShowModal() == wx.ID_OK:
		fname=dlg.GetPath()
	else:
		gui.report("Canceled File Load.")
		return None
	gui.report("Loading file  %s" % fname)
	pars=gui.ga.params()
	w=len(pars._pars)+1	
	if gui.ga.attrib('EvalConditions'):
		w+=int(gui.ga.attrib('EvalConditions'))
	if not ast.verify(fname, w, minlength=1):
		gui.report("File  %s is not an appropriate arraystore (it is not an arraystore at all, it has the wrong width, or it is empty." % fname)
		return None
	return fname
Example #2
0
def testManySteps(w, stfn, N):
	if not astore.verify(stfn, 23):
		astore.empty(stfn, 23)
	a=astore.ArrayStore(stfn, 'w')
	for i in range(N):
		if not i%100:
			print i
		z=randomStep()
		r=testStep(w, z)
		r=concatenate([z, array(r)])
		a.append(r)
		if not r[0]<0:
			print i, r
	a.close()	
Example #3
0
File: gui.py Project: gic888/MIEN
	def __init__(self, parent=None, opt=None):
 		BaseGui.__init__(self, parent, id=-1, title="Optimizer Analysis", menus = ["Data", "Units", "Analysis"], pycommand=True, height=6, memory=100000)
		guicommands=[["Data","Load Data", self.load],
					 ["Data", "Create Data Element", self.save],
					 ["Data","----"],
					 ["Data","Reload Analysis Module", self.bounce],
					 ["Data","Quit", self.quit],
					 ["Units", "Show", self.displayUnit],
					 ["Units", "Assign", self.assign],
					 ["Units", "Re-Evaluate", self.evalUnit]]
		
		self.ga=opt
		self.pars=opt.params()
		self.condition={}
		self.fillMenus(guicommands)

		sizer = wx.BoxSizer(wx.VERTICAL)
		
		self.tit =  wx.StaticText(self.main, -1, 'No Algorithm')
		sizer.Add(self.tit, 1, wx.GROW|wx.ALIGN_CENTRE|wx.ALL, 5)
		self.sizeinf =  wx.StaticText(self.main, -1, ' No Data ')
		sizer.Add(self.sizeinf, 1, wx.GROW|wx.ALIGN_CENTRE|wx.ALL, 5)
		self.stats =  wx.StaticText(self.main, -1, ' -- ')
		sizer.Add(self.stats, 1, wx.GROW|wx.ALIGN_CENTRE|wx.ALL, 5)
		
		
		self.main.SetSizer(sizer)
		self.main.SetAutoLayout(True)
		sizer.Fit(self.main)
		self.SetSize((600,200))
		self.bounce()
		self.np=len(self.pars._pars)
		self.nunits=0
		if opt.attrib('EvalConditions'):
			self.hasEC=opt.attrib('EvalConditions')
		else:
			self.hasEC=0
		storesize=self.np+1+self.hasEC
		self.data=None
		if ast.verify(opt.attrib('File'), storesize, 1):
			self.ast=ast.ArrayStore(opt.attrib('File'), 'w')
		else:	
			self.report("Optimizer File attribute does not refference a valid arraystore. You will need to load data by hand") 
			self.ast=None
		self.showInfo()	
Example #4
0
File: base.py Project: gic888/MIEN
	def resume(self, fname=None):
		'''Resume a run from stored data. This is an alternative to self.prep. If fname isn't specified it defaults to self.attrib("File").'''
		self.initialize_vars()
		if not fname:
			fname=self.attrib("File")
		if not ast.verify(fname, self._storesize):
			self.report("can't resume. %s is not an appropriate storage file" % fname)
			self.prep()
			return 
		self._store=ast.ArrayStore(fname, 'w') 
		self._nunits = len(self._store)
		fit=self._store.getColumn(0)
		if self.attrib('Maximize'):
			bid=argmin(fit)	
		else:
			bid=argmin(fit)	
		self._best=(fit[bid], bid)
		self.report("Resume complete. %i units. Best %.4f, Mean %.4f" % (self._nunits, self._best[0], self.fit.mean()))
		self.setAttrib('File', fname)