예제 #1
0
def main():
    init_logging()
    # init computation
    prms = Parameters()
    Run(run_name=config['Name'], tset_path=config['TraininSetPath']).index = 'DENS-0000'
    trset = TrainingSet(config['TraininSetPath'], config['TraininSetName'])
    # MolSet.p_call_mol_energy('full')
    # print('NEEDEDMOL:',list(map(lambda x: x.id,trset.container[0].container[0].needed_mol)))
    # print('UNIENERGY:',list(map(lambda x: x.uni_energy,trset.container[0].container[0].needed_mol)))
    # print('FULLENERGY:',list(map(lambda x: x.full_energy,trset.container[0].container[0].needed_mol)))
    # print('FUNCENERGY:',list(map(lambda x: x.func_energy,trset.container[0].container[0].needed_mol)))
#    sys.exit()
    # MolSet.p_call_mol_energy('func')
    # for mol in MolSet.container:
    #     print(mol.myprm_full.sprms)
    #     print(mol.myprm_func.sprms)


    prms.prms = dict(tta=[13.300000190734863],
                       ttb=[1.5299999713897705],
                       cxhf=[0.157706],
                       omega=[0.3],
                       cx_aa=[0.842294, 0.726479, 1.04760, -5.70635, 13.2794],
                       cc_aa=[1.000000, -4.33879, 18.2308, -31.7430, 17.2901],
                       cc_ab=[1.000000, 2.37031, -11.3995, 6.58405, -3.78132])

    print(prms._parameters)
#    prms.prms = {'cx_aa_0': 0.5, 'cc_aa_2':12000, 'tta':100}
#    print(trset.compute_MAE('full'))
#    print(prms._parameters)

    prms.optim = ['tta', 'cx_aa_0','cx_aa_1','cx_aa_2','cx_aa_3','cx_aa_4']
    print(prms.optim)
    
    x0_=[13.3, 0.842294, 0.726479, 1.0476, -5.70635, 13.2794]
#    x1_=[13.3, 0.04334172, 2.14371968, 2.0473701, -5.10893517,  13.63496978]
#    x2_=[13.4, 0.05334172, 2.14371968, 2.0473701, -5.10893517,  13.63496978]

    def printer(xc):
       print('END of STEP')
       print(xc)

    bnds=((None,None),(0,None),(None,None),(None,None),(None,None),(None,None))
    print(trset.optimizer(x0_,'full','MAE'))
#   print(trset.optimizer(x1_,'func','MAE'))
#   print(trset.optimizer(x2_,'func','MAE'))
#    print(minimize(trset.optimizer,x0_,args=('func','MAE'),method='L-BFGS-B', callback=printer, bounds=bnds,  options={'disp': True} ))
    print(minimize(trset.optimizer,x0_,args=('func','MAE'), method='TNC', bounds=bnds, callback=printer, options={'disp': True,'ftol': 1e-2 }))
예제 #2
0
def main():
    init_logging()
    lg.debug('test')
    testing = ['params_Parameters']
#    testing = ['trset_DataSet']
#    testing = ['trset_System']

    # Testing make_input
    if 'make_input' in testing:
        newinput = mkinp.Input('test.xyz')
        del newinput

    # Testing Molecule
    if 'trset_Molecule' in testing:
        molpath = '../../example/trset-tree-example/S-022/geometry/001.xyz'
        mol = trset.Molecule(molpath)
        lg.debug(str(mol))

    if 'trset_System' in testing:
        rulep = ('../../example/trset-tree-example/S-022/rule.dat')
        with open(rulep, 'r') as rulef:
            line = rulef.readline()
            while line[0] == '#':
                line = rulef.readline()
        system = trset.System(line, 'S-022')
        lg.info(str(system))
        lg.info(system.fulldft_energy_error())
        lg.info(system.fulldft_energy())
        system.set_fulldft()
        lg.info(system.fulldft_energy())

    if 'trset_DataSet' in testing:
        path = ('../../example/trset-tree-example/S-022')
        dset = trset.DataSet(path)
        print(dset.get_fulldftlist())
        print(dset.get_blacklist())
        dset.add_to_blacklist(['1', '2', '3', '4'])
        dset.add_to_fulldftlist(['5', '6', '3', '4'])
        print(dset.get_fulldftlist())
        print(list(map(lambda x: x.name, dset.get_blacklist())))
        print(list(map(lambda x: x.name, dset.get_fulldftlist())))

    if 'trset_TrainingSet' in testing:
        path = ('../../example/trset-tree-example')
        tset = trset.TrainingSet(path, 'test-tset.dat')
        # print(list(map(str, tset.container)))
        print(tset.get_blacklist())
        print(tset.get_fulldftlist())
        # print(tset.p_compute_MAE('func'))
        print(tset.p_compute_MAE('func'))

    if 'params_Parameters' in testing:

        x = list(range(1, 20))
        # print(x)
        prm = Prm()
        prm1 = Prm()
        print('prm: ', prm.prms)
        print('prm1: ', prm1.prms)
        prm.prms = dict(tta=[1000])
        print('prm: ', prm.prms)
        print('prm1: ', prm1.prms)
        print('sprm1: ', prm1.sprms)
        prm1.sprms = dict(tta=[2])
        print('--------------------')
        print('prm: ', prm.prms)
        print('sprm: ', prm.sprms)
        print('prm validity: ', prm.check_prms())
        print('--------------------')
        print('prm1: ', prm1.prms)
        print('sprm1: ', prm1.sprms)
        print('prm1 validity: ', prm1.check_prms())
        print('--------------------')
        prm1.refresh()
        print('--------------------')
        print('prm1: ', prm1.prms)
        print('sprm1: ', prm1.sprms)
        print('prm1 validity: ', prm1.check_prms())
        print('--------------------')
        print('prm1:     ', prm1.prms)
        print('prm1_old: ', prm1.prms_old)
        print('prm1 check old: ', prm1.check_old())
        print('--------------------')
        prm1.prms = dict(tta=[2])
        print('prm1:     ', prm1.prms)
        print('prm1_old: ', prm1.prms_old)
        print('prm1 check old: ', prm1.check_old())
        prm1.optim = dict(tta=504, cc_aa_1=505)
        print(prm.prms)
        print(prm.check_old())
        print(prm.optim)