def avaliation(num_testes):

    for i in range(num_testes):
        convergencias = 0
        itr_converg = []
        qtd_convergidos = []
        fitness_med = []
        ofile = open('teste' + str(i) + '.csv', "w", newline='')
        writer = csv.writer(ofile)
        #writer.writerow(['config','fitness'])
        print("Teste " + str(i + 1))

        (it_converg, total_converg, fit_medio) = main(False, writer)

        convergencias += 1 if total_converg > 0 else 0

        itr_converg.append(it_converg)
        qtd_convergidos.append(total_converg)
        fitness_med.append(fit_medio)
        ofile.close()

        ofile = open('info' + str(i) + '.csv', "w", newline='')
        writer = csv.writer(ofile)
        #writer.writerow(('dado','valor'))
        writer.writerow(
            (TAM_POPULACAO, total_converg, it_converg, "%.3f" % fit_medio))
def integration(num_testes):

    dir = "cutcross"
    list_modules = os.listdir(dir)
    for module in list_modules:
        if module.split('.')[-1] != 'py':
            list_modules.remove(module)
        #endif
    #endfor
    oinfo = open('info_cutcross.csv', "w", newline='')
    oteste = open('cutcross.csv', "w", newline='')
    writeri = csv.writer(oinfo)
    writert = csv.writer(oteste)
    writeri.writerow(('populacao', 'total_cenverg', 'it_converg', 'fitmedio'))
    writert.writerow(('config', 'fitness'))
    for module in list_modules:
        print(module)
        imp.load_source('module', dir + os.sep + module)
        from module import main
        for i in range(num_testes):
            convergencias = 0
            itr_converg = []
            qtd_convergidos = []
            fitness_med = []
            #writer.writerow(['config','fitness'])
            print("Teste " + str(i + 1))
            (it_converg, total_converg, fit_medio) = main(False, writert)
            convergencias += 1 if total_converg > 0 else 0
            itr_converg.append(it_converg)
            qtd_convergidos.append(total_converg)
            fitness_med.append(fit_medio)
            #writer.writerow(('dado','valor'))
            writeri.writerow(
                (TAM_POPULACAO, total_converg, it_converg, "%.3f" % fit_medio))
            #writer.writerow(('total_converg', total_converg))
            #writer.writerow(('it_converg', it_converg))
            #writer.writerow(('mdconvergidos', statistics.mean(qtd_convergidos)))
            #writer.writerow(('fitmedio', ("%.3f" % fit_medio)))
        # endFor
    #endFor
    oinfo.close()
    oteste.close()
示例#3
0
'''
导入module.py并执行module后的main方法后,方法执行结果不是main
We are in module
'''
from module import main
main()
示例#4
0
 def test_main_returns_None(self):
     self.assertEqual(None, main())
示例#5
0
#!/usr/bin/env python
import logging
import json

from settings import settings
import module


class JsonCrawl(module.Crawler):
    def __init__(self, path):
        module.Crawler.__init__(self)
        self.path = path

    def crawl(self):
        for l in open(self.path):
            yield json.loads(l)


if __name__ == '__main__':
    module.main(JsonCrawl)
示例#6
0
 def test_main_returns_1(self):
     old_module_var = module.var
     module.var = 1
     self.assertEqual(module.var, main())
     self.assertEqual(2, module.var)
     module.var = old_module_var
 def test_main_returns_1(self):
     old_module_var = module.var
     module.var = 1
     self.assertEqual(module.var, main())
     self.assertEqual(2, module.var)
     module.var = old_module_var
示例#8
0
文件: tee.py 项目: JeffAMcGee/crowdy
#!/usr/bin/env python
import logging
import json

from settings import settings
import module

class Tee(module.UserFilter):
    def __init__(self, path):
        module.UserFilter.__init__(self)
        self.path = path

    def ufilter(self, users):
        f = open(self.path,'w+')
        for user in users:
            user['tee'] = 1+user.get('tee',0)
            print>>f, json.dumps(user)
            yield user
        f.close()

if __name__ == '__main__':
    module.main(Tee)
示例#9
0
#!/usr/bin/env python
import logging
import json

from settings import settings
import module

class JsonCrawl(module.Crawler):
    def __init__(self, path):
        module.Crawler.__init__(self)
        self.path = path

    def crawl(self):
        for l in open(self.path):
            yield json.loads(l)

if __name__ == '__main__':
    module.main(JsonCrawl)
示例#10
0
from module import main
main()
示例#11
0
import module
module.main() # 输出We are in module
示例#12
0
'''
Documentation, License etc.

@package module
'''
import module

module.proceedMessage()

if module.updateScript():
    import module
    reload(module)

module.main()
示例#13
0
def imp():
    x = m.main()
    x.run_configurator()
示例#14
0
from module import main

main('aa')
示例#15
0
def imp():
    m.main()
 def test_main_returns_None(self):
     self.assertEqual(None, main())
示例#17
0
文件: tee.py 项目: infolabtamu/crowdy
#!/usr/bin/env python
import logging
import json

from settings import settings
import module


class Tee(module.UserFilter):
    def __init__(self, path):
        module.UserFilter.__init__(self)
        self.path = path

    def ufilter(self, users):
        f = open(self.path, 'w+')
        for user in users:
            user['tee'] = 1 + user.get('tee', 0)
            print >> f, json.dumps(user)
            yield user
        f.close()


if __name__ == '__main__':
    module.main(Tee)