def BBEncounterSchedule(B1_fillingScheme, B2_fillingScheme, BBMatrixLHC): """ It returns a dictionary structure with the BB encounters of B1 and B2 taking into account the filling schemes. - B1_fillingScheme [adimensional integer array]: the B1 filling scheme. - B2_fillingScheme [adimensional integer array]: the B2 filling scheme. The dictionary structure has the following hierarchy: - BEAM >> BUNCH >> EXPERIMENT >> ENCOUNTERS - BEAM >> BUNCH >> EXPERIMENT >> POSITIONS All the positions are referred to the positive direction of B1 (clockwise in LHC). WARNING: the bunch number is defined wrt the negative direction of each beam. === EXAMPLE 1 === from cl2pd import bbFunctions from cl2pd import importData np=importData.np BBMatrixLHC=bbFunctions.computeBBMatrix(numberOfLRToConsider=25) B1_bunches=np.array([0,1,2]) B2_bunches=np.array([0,1,2]) results=beam_BB_pattern(B1_bunches, B2_bunches, BBMatrixLHC) """ experiments = ['atALICE', 'atATLAS', 'atCMS', 'atLHCB'] #B1 B1_BB_pattern = dotdict() for i in B1_fillingScheme: bunch_aux = dotdict() for j in experiments: results = _bunch_BB_pattern(i, BBMatrixLHC) B2 = results['atB1'][j] aux = B2[np.in1d(B2, B2_fillingScheme)] myPosition = np.arange(-(len(B2) - 1) / 2, (len(B2) - 1) / 2 + 1) bunch_aux.update({ j: { 'atEncounters': aux, 'atPositions': myPosition[np.in1d(B2, B2_fillingScheme)] } }) B1_BB_pattern.update({'at' + format(i, '04d'): bunch_aux}) #B2 B2_BB_pattern = dotdict() for i in B2_fillingScheme: bunch_aux = dotdict() for j in experiments: results = _bunch_BB_pattern(i, BBMatrixLHC) B1 = results['atB2'][j] aux = B1[np.in1d(B1, B1_fillingScheme)] myPosition = np.arange(-(len(B1) - 1) / 2, (len(B1) - 1) / 2 + 1) bunch_aux.update({ j: { 'atEncounters': aux, 'atPositions': myPosition[np.in1d(B1, B1_fillingScheme)] } }) B2_BB_pattern.update({'at' + format(i, '04d'): bunch_aux}) beam_BB_pattern = dotdict({'atB1': B1_BB_pattern, 'atB2': B2_BB_pattern}) return beam_BB_pattern
def dictOpticsFromMADX(B1_twiss, B2_twiss, B1_survey, B2_survey): """ This functions transforms the 4 DFs obtained from MAD-X into a dotdict with autocompletetion. The output structure would be MADX_DICT.BEAM.Survey (or Twiss) """ B1opticsDic = dotdict({'Twiss': B1_twiss, 'Survey': B1_survey}) B2opticsDic = dotdict({'Twiss': B2_twiss, 'Survey': B2_survey}) return dotdict({'B1': B1opticsDic, 'B2': B2opticsDic})
def filterOpticsDF(BBES, beam, exp, bunch, B1Optics_BB, B2Optics_BB, removeHO=True): ''' This function aims to filter the optics wrt to the previsouly prepared BBES structure. Please set "removeHO" to False in case you want to conserve the HO in the optics. ''' # Copy B1Optics = B1Optics_BB[np.in1d( B1Optics_BB.index, BBES[beam][bunch][exp]['B1_RDV_position'])].copy() B2Optics = B2Optics_BB[np.in1d( B2Optics_BB.index, BBES[beam][bunch][exp]['B2_RDV_position'])].copy() # Partners B1Optics['partners'] = BBES[beam][bunch][exp]['partners'] B2Optics['partners'] = BBES[beam][bunch][exp]['partners'] if removeHO == True: # Removing the HO myIP = 'IP' + exp[2] myHO = 'BBLR_' + myIP + '_HO' + '.' + 'B1' B1Optics = B1Optics[B1Optics.NAME != myHO] myHO = 'BBLR_' + myIP + '_HO' + '.' + 'B2' B2Optics = B2Optics[B2Optics.NAME != myHO] return dotdict({'B1Optics': B1Optics, 'B2Optics': B2Optics})
def _beam_BB_pattern(BBMatrixLHC, B1_fillingScheme=np.array([0, 1, 2, 3]), B2_fillingScheme=np.array([0, 1, 2, 3])): """ It returns a dictionary structure with the BB encounters of B1 and B2 taking into account the filling schemes. - BBMatrixLHC [adimensional integer array]: the LHC BB matrix - B1_fillingScheme [adimensional integer array]: the B1 filling scheme. - B2_fillingScheme [adimensional integer array]: the B2 filling scheme. The dictionary structure has the following hierarchy: - BEAM >> BUNCH >> EXPERIMENT >> PARTNERS - BEAM >> BUNCH >> EXPERIMENT >> RDV_INDEX All the positions are referred to the positive direction of B1 (clockwise in LHC). WARNING: the bunch number is defined wrt the negative direction of each beam. """ experiments = ['IR1', 'IR2', 'IR5', 'IR8'] #B1 B1_BB_pattern = dotdict({}) for i in B1_fillingScheme: bunch_aux = dotdict({}) results = _bunch_BB_pattern(Bunch=i, BBMatrixLHC=BBMatrixLHC) for j in experiments: bunch_exp = dotdict({}) B1 = results['B2'][j] aux = np.intersect1d(B1, B2_fillingScheme) myPosition = -((np.where(np.in1d(B1, aux))[0]) - (len(B1) - 1) / 2) bunch_exp.update({ 'partners': aux, 'RDV_index': myPosition[-1::-1] }) bunch_aux.update({str(j): bunch_exp}) B1_BB_pattern.update({'b' + str(i): bunch_aux}) #B2 B2_BB_pattern = dotdict({}) for i in B2_fillingScheme: bunch_aux = dotdict({}) results = _bunch_BB_pattern(Bunch=i, BBMatrixLHC=BBMatrixLHC) for j in experiments: bunch_exp = dotdict({}) B2 = results['B2'][ j] # Full machine --> TODO: write it in a more symmetric way... aux = np.intersect1d(B2, B1_fillingScheme) myPosition = ((np.where(np.in1d(B2, aux))[0]) - (len(B2) - 1) / 2) bunch_exp.update({ 'partners': aux, 'RDV_index': myPosition[-1::-1] }) bunch_aux.update({str(j): bunch_exp}) B2_BB_pattern.update({'b' + str(i): bunch_aux}) beam_BB_pattern = {'B1': B1_BB_pattern, 'B2': B2_BB_pattern} return dotdict(beam_BB_pattern)
def preparingOpticsFromMADX(MADX_DICT): """ This function makes all the required optics post process needed to compute BB related values. The input is a dotdict containing the survey and the twiss from MAD-X for each beam. The output has the same structure, but contains post-processed data. NB: as the input is a dotdict, please prepare the optics data in such a structure using _dictOpticsFromMADX ===== EXAMPLE ===== MADX_DICT = preparingOpticsFromMADX(dictOpticsFromMADX(B1_twiss,B2_twiss,B1_survey,B2_survey)) """ # Mirroring B1_mirrored = MADX_DICT.B1.Twiss.copy() B1_mirrored.index = B1_mirrored.index - MADX_DICT.B1.Twiss.index[-1] B1_mirrored['S'] = B1_mirrored['S'] - MADX_DICT.B1.Twiss.index[-1] B2_mirrored = MADX_DICT.B2.Twiss.copy() B2_mirrored.index = B2_mirrored.index - MADX_DICT.B2.Twiss.index[-1] B2_mirrored['S'] = B2_mirrored['S'] - MADX_DICT.B2.Twiss.index[-1] B1 = pd.concat([B1_mirrored, MADX_DICT.B1.Twiss]) B2 = pd.concat([B2_mirrored, MADX_DICT.B2.Twiss]) B1SurveyMirrored = MADX_DICT.B1.Survey.copy() B1SurveyMirrored.index = B1SurveyMirrored.index - MADX_DICT.B1.Survey.index[ -1] B1SurveyMirrored[ 'S'] = B1SurveyMirrored['S'] - MADX_DICT.B1.Survey.index[-1] B2SurveyMirrored = MADX_DICT.B2.Survey.copy() B2SurveyMirrored.index = B2SurveyMirrored.index - MADX_DICT.B2.Survey.index[ -1] B2SurveyMirrored[ 'S'] = B2SurveyMirrored['S'] - MADX_DICT.B2.Survey.index[-1] # B1/2 survey B1_survey = pd.concat([B1SurveyMirrored, MADX_DICT.B1.Survey]) B2_survey = pd.concat([B2SurveyMirrored, MADX_DICT.B2.Survey]) #######========== SURVEY ==========####### # Filtering B1 and B2 DFs, in order to fullfill two conditions: # - in the 8 Long straight sections they are a n x Delta from the IR, Delta~25 ns *c (B1 and B2 DFs must have the # same length but not the same s) # - in the arcs the mechanical distance of the two reference orbits in s^{B1}_i and s^{B2}_i is 19.4 mm. myFilter = ((B1_survey['NAME'].str.contains('^MB\..*B1$')) | (B1_survey['NAME'].str.contains('^E\.')) | (B1_survey['NAME'].str.contains('BBLR')) | (B1_survey['NAME'].str.contains('^S\.'))) B1_survey_filter = B1_survey[myFilter].copy() myFilter = ((B2_survey['NAME'].str.contains('^MB\..*B2$')) | (B2_survey['NAME'].str.contains('^E\.')) | (B2_survey['NAME'].str.contains('BBLR')) | (B2_survey['NAME'].str.contains('^S\.'))) B2_survey_filter = B2_survey[myFilter].copy() # DeltaX and Delta Z computation from survey, taking into account the angle Theta DeltaX = B2_survey_filter['X'].values - B1_survey_filter['X'].values DeltaY = B2_survey_filter['Z'].values - B1_survey_filter['Z'].values meanTheta = (B1_survey_filter['THETA'].values + B2_survey_filter['THETA'].values) / 2. myDeltaX = np.cos(meanTheta) * DeltaX - np.sin(meanTheta) * DeltaY myDeltaZ = np.sin(meanTheta) * DeltaX + np.cos(meanTheta) * DeltaY B1_survey_filter['myDeltaZ'] = myDeltaZ B1_survey_filter['myDeltaX'] = myDeltaX DeltaX = -B2_survey_filter['X'].values + B1_survey_filter['X'].values DeltaY = -B2_survey_filter['Z'].values + B1_survey_filter['Z'].values meanTheta = (B1_survey_filter['THETA'].values + B2_survey_filter['THETA'].values) / 2. myDeltaX = np.cos(meanTheta) * DeltaX - np.sin(meanTheta) * DeltaY myDeltaZ = np.sin(meanTheta) * DeltaX + np.cos(meanTheta) * DeltaY B2_survey_filter['myDeltaZ'] = myDeltaZ B2_survey_filter['myDeltaX'] = myDeltaX # Phase advance at the IPS B1 muX_IP1L = B1[B1['NAME'] == 'IP1.L1']['MUX'].values[0] muY_IP1L = B1[B1['NAME'] == 'IP1.L1']['MUY'].values[0] muX_IP2 = B1[B1['NAME'] == 'IP2']['MUX'].values[0] muY_IP2 = B1[B1['NAME'] == 'IP2']['MUY'].values[0] muX_IP3 = B1[B1['NAME'] == 'IP3']['MUX'].values[0] muY_IP3 = B1[B1['NAME'] == 'IP3']['MUY'].values[0] muX_IP4 = B1[B1['NAME'] == 'IP4']['MUX'].values[0] muY_IP4 = B1[B1['NAME'] == 'IP4']['MUY'].values[0] muX_IP5 = B1[B1['NAME'] == 'IP5']['MUX'].values[0] muY_IP5 = B1[B1['NAME'] == 'IP5']['MUY'].values[0] muX_IP6 = B1[B1['NAME'] == 'IP6']['MUX'].values[0] muY_IP6 = B1[B1['NAME'] == 'IP6']['MUY'].values[0] muX_IP7 = B1[B1['NAME'] == 'IP7']['MUX'].values[0] muY_IP7 = B1[B1['NAME'] == 'IP7']['MUY'].values[0] muX_IP8 = B1[B1['NAME'] == 'IP8']['MUX'].values[0] muY_IP8 = B1[B1['NAME'] == 'IP8']['MUY'].values[0] #######========== TWISS ==========####### # Filtering B1 and B2 DFs, in order to fullfill two conditions: # - in the 8 Long straight sections they are a n x Delta from the IR, Delta~25 ns *c (B1 and B2 DFs must have the # same length but not the same s) # - in the arcs the mechanical distance of the two reference orbits in s^{B1}_i and s^{B2}_i is 19.4 mm. myFilter = ((B1['NAME'].str.contains('^MB\..*B1$')) | (B1['NAME'].str.contains('^E\.')) | (B1['NAME'].str.contains('BBLR')) | (B1['NAME'].str.contains('^S\.'))) B1_twiss_filter = B1[myFilter].copy() B1_twiss_filter['Delta MUX'] = 0 B1_twiss_filter['Delta MUY'] = 0 B1_twiss_filter['Ideal MUX'] = 0 B1_twiss_filter['Ideal MUY'] = 0 for i in B1_twiss_filter.index: if 'IP1_L' in B1_twiss_filter.loc[i, 'NAME']: B1_twiss_filter.loc[i, 'Delta MUX'] = -(muX_IP1L - B1_twiss_filter.loc[i, 'MUX']) B1_twiss_filter.loc[i, 'Ideal MUX'] = -0.25 B1_twiss_filter.loc[i, 'Delta MUY'] = -(muY_IP1L - B1_twiss_filter.loc[i, 'MUY']) B1_twiss_filter.loc[i, 'Ideal MUY'] = -0.25 if 'IP1_R' in B1_twiss_filter.loc[i, 'NAME']: B1_twiss_filter.loc[i, 'Delta MUX'] = B1_twiss_filter.loc[i, 'MUX'] B1_twiss_filter.loc[i, 'Ideal MUX'] = 0.25 B1_twiss_filter.loc[i, 'Delta MUY'] = B1_twiss_filter.loc[i, 'MUX'] B1_twiss_filter.loc[i, 'Ideal MUY'] = 0.25 if 'IP5_L' in B1_twiss_filter.loc[i, 'NAME']: B1_twiss_filter.loc[ i, 'Delta MUX'] = B1_twiss_filter.loc[i, 'MUX'] - muX_IP5 B1_twiss_filter.loc[i, 'Ideal MUX'] = -0.25 B1_twiss_filter.loc[ i, 'Delta MUY'] = B1_twiss_filter.loc[i, 'MUY'] - muY_IP5 B1_twiss_filter.loc[i, 'Ideal MUY'] = -0.25 if 'IP5_R' in B1_twiss_filter.loc[i, 'NAME']: B1_twiss_filter.loc[ i, 'Delta MUX'] = B1_twiss_filter.loc[i, 'MUX'] - muX_IP5 B1_twiss_filter.loc[i, 'Ideal MUX'] = 0.25 B1_twiss_filter.loc[ i, 'Delta MUY'] = B1_twiss_filter.loc[i, 'MUY'] - muY_IP5 B1_twiss_filter.loc[i, 'Ideal MUY'] = 0.25 myFilter = ((B2['NAME'].str.contains('^MB\..*B2$')) | (B2['NAME'].str.contains('^E\.')) | (B2['NAME'].str.contains('BBLR')) | (B2['NAME'].str.contains('^S\.'))) B2_twiss_filter = B2[myFilter].copy() B2_twiss_filter['Delta MUX'] = 0 B2_twiss_filter['Delta MUY'] = 0 B2_twiss_filter['Ideal MUX'] = 0 B2_twiss_filter['Ideal MUY'] = 0 # Phase advance at the IPS B2 muX_IP1L = B2[B2['NAME'] == 'IP1.L1']['MUX'].values[0] muY_IP1L = B2[B2['NAME'] == 'IP1.L1']['MUY'].values[0] muX_IP2 = B2[B2['NAME'] == 'IP2']['MUX'].values[0] muY_IP2 = B2[B2['NAME'] == 'IP2']['MUY'].values[0] muX_IP3 = B2[B2['NAME'] == 'IP3']['MUX'].values[0] muY_IP3 = B2[B2['NAME'] == 'IP3']['MUY'].values[0] muX_IP4 = B2[B2['NAME'] == 'IP4']['MUX'].values[0] muY_IP4 = B2[B2['NAME'] == 'IP4']['MUY'].values[0] muX_IP5 = B2[B2['NAME'] == 'IP5']['MUX'].values[0] muY_IP5 = B2[B2['NAME'] == 'IP5']['MUY'].values[0] muX_IP6 = B2[B2['NAME'] == 'IP6']['MUX'].values[0] muY_IP6 = B2[B2['NAME'] == 'IP6']['MUY'].values[0] muX_IP7 = B2[B2['NAME'] == 'IP7']['MUX'].values[0] muY_IP7 = B2[B2['NAME'] == 'IP7']['MUY'].values[0] muX_IP8 = B2[B2['NAME'] == 'IP8']['MUX'].values[0] muY_IP8 = B2[B2['NAME'] == 'IP8']['MUY'].values[0] for i in B2_twiss_filter.index: if 'IP1_L' in B2_twiss_filter.loc[i, 'NAME']: B2_twiss_filter.loc[i, 'Delta MUX'] = -(muX_IP1L - B1_twiss_filter.loc[i, 'MUX']) B2_twiss_filter.loc[i, 'Ideal MUX'] = -0.25 B2_twiss_filter.loc[i, 'Delta MUY'] = -(muY_IP1L - B1_twiss_filter.loc[i, 'MUY']) B2_twiss_filter.loc[i, 'Ideal MUY'] = -0.25 if 'IP1_R' in B2_twiss_filter.loc[i, 'NAME']: B2_twiss_filter.loc[i, 'Delta MUX'] = B1_twiss_filter.loc[i, 'MUX'] B2_twiss_filter.loc[i, 'Ideal MUX'] = 0.25 B2_twiss_filter.loc[i, 'Delta MUY'] = B1_twiss_filter.loc[i, 'MUX'] B2_twiss_filter.loc[i, 'Ideal MUY'] = 0.25 if 'IP5_L' in B2_twiss_filter.loc[i, 'NAME']: B2_twiss_filter.loc[ i, 'Delta MUX'] = B2_twiss_filter.loc[i, 'MUX'] - muX_IP5 B2_twiss_filter.loc[i, 'Ideal MUX'] = -0.25 B2_twiss_filter.loc[ i, 'Delta MUY'] = B2_twiss_filter.loc[i, 'MUY'] - muY_IP5 B2_twiss_filter.loc[i, 'Ideal MUY'] = -0.25 if 'IP5_R' in B2_twiss_filter.loc[i, 'NAME']: B2_twiss_filter.loc[ i, 'Delta MUX'] = B2_twiss_filter.loc[i, 'MUX'] - muX_IP5 B2_twiss_filter.loc[i, 'Ideal MUX'] = 0.25 B2_twiss_filter.loc[ i, 'Delta MUY'] = B2_twiss_filter.loc[i, 'MUY'] - muY_IP5 B2_twiss_filter.loc[i, 'Ideal MUY'] = 0.25 B1_twiss_filter[ 'myDeltaX'] = B2_twiss_filter['X'].values - B1_twiss_filter['X'].values B1_twiss_filter[ 'myDeltaZ'] = B2_twiss_filter['Y'].values - B1_twiss_filter['Y'].values B2_twiss_filter[ 'myDeltaX'] = B1_twiss_filter['X'].values - B2_twiss_filter['X'].values B2_twiss_filter[ 'myDeltaZ'] = B1_twiss_filter['Y'].values - B2_twiss_filter['Y'].values B1_twiss_filter['B2-B1 complex distance']= (B1_twiss_filter['myDeltaX']+B1_survey_filter['myDeltaX']) \ + 1j*(B1_twiss_filter['myDeltaZ']+B1_survey_filter['myDeltaZ']) B2_twiss_filter['B1-B2 complex distance']= (B2_twiss_filter['myDeltaX']+B2_survey_filter['myDeltaX']) \ + 1j*(B2_twiss_filter['myDeltaZ']+B2_survey_filter['myDeltaZ']) B1opticsDic = dotdict({ 'Twiss': B1_twiss_filter, 'Survey': B1_survey_filter }) B2opticsDic = dotdict({ 'Twiss': B2_twiss_filter, 'Survey': B1_survey_filter }) return dotdict({'B1': B1opticsDic, 'B2': B2opticsDic})
def _bunch_BB_pattern(Bunch, BBMatrixLHC): ''' It returns the beam-beam pattern of a bunch of B1 and B2 [adimensional array of integer] in ALICE, ATLAS, CMS, LHCB. - Bunch [adimensional integer]: the bunch number in B1 and B2 to consider. - BBMatrixLHC [adimensional integer matrix]: the beam-beam matrix to consider (see bbFunctions.computeBBMatrix?). The returned array is ordered with respect to the positive direction of B1 (clockwise in LHC). WARNING: the bunch number is defined wrt the negative direction of each beam. Conventions : ...=>B1 bunch 1 => B1 bunch 0 => |[IP]| <= B2 bunch 0 <= B2 bunch 1 <=... This means that B1 bunch 0 will meet B2 bunch 1 on the positive side of the IP and B2 bunch 0 will meet B1 bunch 0 on the negative side of IP1 (positive/negative wrt the B1). ''' #### BEAM 1 #### BBVector = BBMatrixLHC[Bunch, :] numberOfLRToConsider = len(np.where(BBMatrixLHC[Bunch, :] == 10)[0]) / 2 HO_in_IP = BBVector == 1 LR_in_IP = BBVector == 10 aux = np.where((LR_in_IP) | (HO_in_IP))[0] np.where(aux == Bunch)[0] B1 = np.roll( aux, numberOfLRToConsider - np.where(aux == np.where(HO_in_IP)[0][0])[0]) resultsB1 = dotdict({'atATLAS': B1, 'atCMS': B1}) HO_in_IP = BBVector == 2 LR_in_IP = BBVector == 20 numberOfLRToConsider = len(np.where(BBMatrixLHC[Bunch, :] == 20)[0]) / 2 aux = np.where((LR_in_IP) | (HO_in_IP))[0] np.where(aux == Bunch)[0] B1 = np.roll( aux, numberOfLRToConsider - np.where(aux == np.where(HO_in_IP)[0][0])[0]) resultsB1.update({'atALICE': B1}) HO_in_IP = BBVector == 8 LR_in_IP = BBVector == 80 numberOfLRToConsider = len(np.where(BBMatrixLHC[Bunch, :] == 80)[0]) / 2 aux = np.where((LR_in_IP) | (HO_in_IP))[0] np.where(aux == Bunch)[0] B1 = np.roll( aux, numberOfLRToConsider - np.where(aux == np.where(HO_in_IP)[0][0])[0]) resultsB1.update({'atLHCB': B1}) #### BEAM 2 #### BBVector = BBMatrixLHC[:, Bunch] numberOfLRToConsider = len(np.where(BBMatrixLHC[Bunch, :] == 10)[0]) / 2 HO_in_IP = BBVector == 1 LR_in_IP = BBVector == 10 aux = np.where((LR_in_IP) | (HO_in_IP))[0] np.where(aux == Bunch)[0] B2 = np.roll( aux, numberOfLRToConsider - np.where(aux == np.where(HO_in_IP)[0][0])[0]) resultsB2 = dotdict({ 'atATLAS': B2[::-1], 'atCMS': B2[::-1] }) # To note the inverstion of the direction HO_in_IP = BBVector == 2 LR_in_IP = BBVector == 20 numberOfLRToConsider = len(np.where(BBMatrixLHC[Bunch, :] == 20)[0]) / 2 aux = np.where((LR_in_IP) | (HO_in_IP))[0] np.where(aux == Bunch)[0] B2 = np.roll( aux, numberOfLRToConsider - np.where(aux == np.where(HO_in_IP)[0][0])[0]) resultsB2.update({'atALICE': B2[::-1]}) HO_in_IP = BBVector == 8 LR_in_IP = BBVector == 80 numberOfLRToConsider = len(np.where(BBMatrixLHC[Bunch, :] == 80)[0]) / 2 aux = np.where((LR_in_IP) | (HO_in_IP))[0] np.where(aux == Bunch)[0] B2 = np.roll( aux, numberOfLRToConsider - np.where(aux == np.where(HO_in_IP)[0][0])[0]) resultsB2.update({'atLHCB': B2[::-1]}) # The encounters seen by B1/2 are in increasing/decreasing order return dotdict({'atB1': resultsB1, 'atB2': resultsB2})
import random import numpy as np import math import sys sys.path.append('../../') from dotdict import * from utils import Bar, AverageMeter from NeuralNet import NeuralNet import tensorflow as tf from .BinPackNNet import BinPackNNet as onnet args = dotdict({ 'lr': 0.001, 'dropout': 0.3, 'epochs': 200, 'batch_size': 32, 'num_channels': 512, }) class NNetWrapper(NeuralNet): def __init__(self, game): self.nnet = onnet(game, args) self.board_x, self.board_y, self.channels = game.getBoardSize() self.action_size = game.getActionSize() self.sess = tf.Session(graph=self.nnet.graph) self.saver = None with tf.Session() as temp_sess:
# print("p_out, v_out: ", p_out.shape, v_out.shape) return p_out, v_out args = dotdict({ 'cuda': torch.cuda.is_available(), 'board_size': BOARD_SIZE, 'action_size': NUM_ACTIONS, 'num_features': NUM_FEATURES, 'num_layers': NUM_LAYERS, 'num_channels': 256, 'epochs': NUM_EPOCHS, 'batch_size': BATCH_SIZE, 'mini_batch': 2048, 'lr': 0.001, 'dropout': 0.3, 'momentum': 0.9, 'l2': 0.0001, 'num_checkpoint': 1000, 'temp1': 1, 'epsilon': 0.25, 'eta': 0.03 # 'total_games':500000, # 'num_simulations':1600, # 'num_games':400, # 'threshold_win':0.55, # 'num_selfplay': 2500, }) class AlphaLoss(nn.Module): """