예제 #1
0
파일: worker.py 프로젝트: Ralf3/samt2
    def fill_new_fuz_with_inputs(self, mfRangeList, mfTitleList, 
					mfTypeList, inputname, anz1): 
	# called by: switchTab=3,4,5,6 --> fill_input_lists, 
	# only for ONE input with inputname 
	li_range = mfRangeList		
	li_title = mfTitleList
	li_type = mfTypeList
	anz_inp = anz1
	inam = inputname     
	
	self.ip_neu = Pyfuzzy.input(inam)  # new input
	
	for j in range(len(li_range)):
	    li_xval = []
	    mname = li_title[j]
	    mtyp = li_type[j]	# 'left',...
	    typflag = self.d_fuzz_flag[mtyp]
	    for v in li_range[j]:
		li_xval.append(round(float(v), 3)) 
	    
	    # Sonderfall:  if mtyp = "left" 
	    # dann li_xval[0] u. li_xval[1] löschen
	    # damit in member.init: 0.Wert=self.ro und 1.Wert=self.ru 
	    if mtyp=="left":
		del li_xval[0:2]
	    
	    # muss self.memb_neu geleert werden???
	    self.memb_neu = Pyfuzzy.member(mname,typflag,li_xval) # new member
	    
	    # dem input-obj hinzufügen
	    self.ip_neu.set_member(mname,mtyp,li_xval)
	
	self.fx_neu.add_input(self.ip_neu)	
	anz = self.ip_neu.get_len()
	n = self.ip_neu.get_n()
예제 #2
0
파일: worker.py 프로젝트: Ralf3/samt2
    def add_model_fuz(self, filename, modelname):
	"""	called from: fileOpen
		adds a new model from filesystem  (.fis) with:
	in:	filename incl. path     str
		modelname		str 
	out:	name of the new model or None
		model_new		str
	if model_name is already in dict self.d_fuz then:
	add a 1 to the name to make it unique """
	modelname_new = modelname
        while(modelname_new in self.d_fuzz):
            modelname_new += "1"
	    
	self.fx =  Pyfuzzy.read_model(filename, DEBUG=1)

	#~ for i in range(len(self.fx.inputs)):
	    #~ for li in self.fx.inputs[i]:
		#~ for j in range(len(li)):
		    #~ print "self.fx.inputs:: ", self.fx.inputs[i][j]	
	
	li_inp = self.fx.get_inputs()
	for i in range(len(li_inp)):
	    li_memb = self.get_members_of_input(li_inp[i])
	
	self.d_fuzz[modelname_new] = self.fx
	return modelname_new   # fx only for inside of class worker 
예제 #3
0
파일: worker.py 프로젝트: Ralf3/samt2
    def fill_new_fuz_with_outputs(self, oname, outputTitleList, xOut):
	# called by: switchTabs 3=Analysis, 4=Calc, 5=Training, 6
	anz_out = len(outputTitleList)
	for j in range(anz_out):
	    onamj = outputTitleList[j]
	    oval = round(xOut[j], 3)
	    self.out_neu = Pyfuzzy.output(onamj,oval)
	    self.fx_neu.add_output(self.out_neu)
	self.fx_neu.set_oname(oname)
예제 #4
0
파일: gisdoc.py 프로젝트: Ralf3/samt2
    def add_model_fuz(self, filename, modelname):
	"""
	    adds a new model from filesystem  (.fis) with:
	    in:		filename incl. path     str
			modelname		str 
	    out:	name of the new model or None
			dataset_new		str
	    if dataset_name is already in dict self.d_models_fuz then:
	    add a 1 to the name to make it unique
	    result: add the model in self.d_models_fuz an in TREE
        """
	ds_new = modelname
        #while(ds_new in self.d_models_fuz):
	while((ds_new in self.d_models_svm) or (ds_new in self.d_models_fuz)):
            ds_new += "1"
	fx =  Pyfuzzy.read_model(filename)
	self.d_models_fuz[ds_new] = fx
	#print self.d_models_fuz.items()
	return ds_new
예제 #5
0
파일: test3.py 프로젝트: yanfeng1022/samt2
#!/usr/bin/env python

# reads a one dimensional fuzzy model and a training data set
# to train rules
# the result will be stored as fuzzy model

import sys
sys.path.append('../')
import Pyfuzzy as fuzz

# adapt this for different tests
f1=fuzz.read_model('hab_schreiadler.fis',DEBUG=1)
x,y=f1.read_training_data('hab_data.csv', header=1)
f1.train_rules(x,y,0.75)  # check the influence of different alpha
f1.store_model('hab')
예제 #6
0
파일: worker.py 프로젝트: Ralf3/samt2
    def train_start(self):
	# called by: btn_trainStart
	Pyfuzzy.start_training(self.fx)
예제 #7
0
파일: worker.py 프로젝트: Ralf3/samt2
    def create_fx_neu(self, modelname):
	# called by: fill_input_lists_for_new_fuz()
	self.fx_neu = Pyfuzzy.fuzzy()
	self.fx_neu.set_name(str(modelname))
예제 #8
0
파일: worker.py 프로젝트: Ralf3/samt2
    def fill_new_fuz_with_rules(self, rulesList):
	# called by: switchTabs 3=Analysis, 4=Calc, 5=Training, 6
	for li_one_rule in rulesList:
	    self.rule_neu = Pyfuzzy.rule(li_one_rule)  # new rule
	    self.fx_neu.add_rule(self.rule_neu)
예제 #9
0
#!/usr/bin/env python

# reads in a fuzzy model and generates a noisy set of data for
# training of it
import sys

sys.path.append('../')
import Pyfuzzy as fuzz
import numpy as np

# change this for different models

f1 = fuzz.read_model('nahr_schreiadler.fis', DEBUG=0)
datasize = 500
x1min = 0.0
x1max = 1.0
x2min = 0.0
x2max = 300.0

# generate the training data
print 'x1,x2,y'
for i in range(datasize):
    x1 = (x1max - x1min) * np.random.rand() + x1min
    x2 = (x2max - x2min) * np.random.rand() + x2min
    y = f1.calc2(x1, x2)
    y = np.random.normal(y, 0.1)  # add some noise
    print x1, x2, y
예제 #10
0
파일: test2.py 프로젝트: yanfeng1022/samt2
#!/usr/bin/env python

# reads a one dimensional fuzzy model and a training data set
# to train rules
# the result will be stored as fuzzy model

import sys
sys.path.append('../')
import Pyfuzzy as fuzz

# adapt this for different tests
f1=fuzz.read_model('nahr_schreiadler.fis',DEBUG=1)
x,y=f1.read_training_data('nahr_data.csv', header=1)
f1.train_rules(x,y,0.75)  # check the influence of different alpha
f1.store_model('nahr')
예제 #11
0
#!/usr/bin/env python

# reads a one dimensional fuzzy model and a training data set
# to train rules
# the result will be stored as fuzzy model

import sys
sys.path.append('../')
import Pyfuzzy as fuzz

# adapt this for different tests
f1 = fuzz.read_model('hab_schreiadler.fis', DEBUG=1)
x, y = f1.read_training_data('hab_data.csv', header=1)
f1.train_rules(x, y, 0.75)  # check the influence of different alpha
f1.store_model('hab')
예제 #12
0
#!/usr/bin/env python

# reads a one dimensional fuzzy model and a training data set
# to train rules
# the result will be stored as fuzzy model

import sys
sys.path.append('../')
import Pyfuzzy as fuzz

# adapt this for different tests
f1 = fuzz.read_model('gen_data1.fis', DEBUG=1)
x, y = f1.read_training_data('data1.csv', header=1)
f1.train_rules(x, y, 0.75)  # check the influence of different alpha
f1.store_model('data1')
예제 #13
0
    Landscape, Wind, Climate
"""

import sys
import os
sys.path.append(os.environ["SAMT2MASTER"] + '/fuzzy/src')
import Pyfuzzy as fuzz
sys.path.append(os.environ["SAMT2MASTER"] + '/src')
import grid as samt2
import time

# load fuzzy model
# path='/home/kerkow/Aufbau_Fuzzy/Modell/Version3/'
# path='/datadisk/pya/culifo_June_2018/culifo_regional/'
path = '/datadisk/Mosquito-Modeling/Regional/'
f = fuzz.read_model(path + 'LandscapeMosquitoes3.fis')
path = '/datadisk/Mosquito-Modeling/Regional/data/'

# load the ASCII or HDF-files
landscape = samt2.grid()
landscape.read_ascii(path + 'Landscape_Version2_MW_7.asc')
wind = samt2.grid()
wind.read_hdf(path + 'wind100m.hdf', 'wind100m')
climate = samt2.grid()
climate.read_ascii(path + 'ClimateSuitability_1981_2010_100m.asc')
#climate.read_ascii(path+'ClimateModelOutputs_callibrated/ClimateSuitability_2051_2080_100m.asc')
#
# start the simulation
t0 = time.time()
modell = f.grid_calc3(landscape, wind, climate)
print('calc time:', time.time() - t0)
예제 #14
0
파일: test1.py 프로젝트: yanfeng1022/samt2
#!/usr/bin/env python

# reads a one dimensional fuzzy model and a training data set
# to train rules
# the result will be stored as fuzzy model

import sys
sys.path.append('../')
import Pyfuzzy as fuzz

# adapt this for different tests
f1=fuzz.read_model('gen_data1.fis',DEBUG=1)
x,y=f1.read_training_data('data1.csv', header=1)
f1.train_rules(x,y,0.75)  # check the influence of different alpha
f1.store_model('data1')