예제 #1
0
for k in isf.flatten(sampleProblems):
    iw, iv, ic, ip, instanceType, solution = isf.extractInstance(dataDec, k)
    isf.exportInstance(iw, iv, ic, ip, k, instanceType, solution, folderOut,
                       instanceNumber)
    instanceNumber = instanceNumber + 1

## INSTANCE ORDER GENERATION and param2.txt + paramMRI.txt export

# Generates the instance randomization order for bN blocks of tN trials for nTypes instance types
nInstances = tN * bN
for i in range(0, nOrderRandomizations):
    instanceOrder = isf.generateInstanceOrder(tN, bN, sampleSizePerBin)

    #Exports 'param2.txt' with the required input for the task

    isf.exportTaskInfo(tN, bN, instanceOrder, nInstances, folderOut, i)

#Generates Intertrial intervals and exports it to paramMRI.txt
isf.exportITIs(tN, bN, folderOut)

######################
# SAT and MZN instanceType Comparison #

dataS = dataSAT[0]
dataS = isf.binCapProf(dataS, nbins)
dataS = isf.addInstanceType(dataS, nCap, nProf, nProfNO, nProfYES, quantileLow,
                            quantileUpper, 'decisions')

#Subset the data frame and change the name of dataInstance
dataM = dataMZN[0]
dataM = isf.binCapProf(dataM, nbins)
nTypesDec = 6

# Samples randomly from each instance-type sampleSizePerBin
# Output: list of sublists. Each sublist has sampleSizePerBin size with the instances ID
sizePerBin = int(tNDec * bNDec / (nTypesDec + 2))
#Total number (Including all blocks) instances per Type
sampleSizePerBin = [
    sizePerBin, sizePerBin, sizePerBin, sizePerBin, 2 * sizePerBin,
    2 * sizePerBin
]

nInstances = tNDec * bNDec
for i in range(nOrderRandomizationsMin, nOrderRandomizations):
    instanceOrder = isf.generateInstanceOrder(tNDec, bNDec, sampleSizePerBin)
    isf.exportTaskInfo(
        tNDec, bNDec, instanceOrder, nInstances, folderOutDec,
        i)  #Exports 'param2.txt' with the required input for the task

#Optimisation
folderOutOpt = folder + 'KS-IC/Data/Simulations/instanceSelectionOutput/optimisation/'
#folderOutOpt='/Users/juanpf/Google Drive/Melbourne/UNIMELB/Complexity Project/Code/Instance Selection/output/optimization/'

#bN blocks of tN trials
#requires tN to be multiple of the number of instances types there are
tNOpt = 9
bNOpt = 2
possibleTypesOpt = [1, 3, 5]

nTypesOpt = len(possibleTypesOpt)
sizePerBin = int(tNOpt * bNOpt / (nTypesOpt))
sampleSizePerBin = [sizePerBin, sizePerBin, sizePerBin]