bNDec = 7

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)
Exemplo n.º 2
0
                                             possibleTypes)

#Exports all the instance files in the sampleProblems list
instanceNumber = 1
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')
#Exports all the instance files in the sampleProblems list
instanceNumber=1
ratioIndex=0
for k in isf.flatten(sampleProblems):
    iw,iv,ic,ip,instanceType,solution=isf.extractInstance(dataDec,k)
    if(instanceType != -1):
        ratioQ=-1
    else:
        solution=ratioRandomization[ratioIndex]
        ratioIndex=ratioIndex+1
        indeces=range(0,len(iw))
        c=[float(iv[x])/float(iw[x]) for x in indeces]
        if(solution==0):
            ratioQ=int(max(c)*2)/2 + 1
        else:
            ratioQ=int(max(c)*2)/2 - 0.5
            if(ratioQ<=0):
                ratioQ=(int(max(c)*2)/2)*0.5
    isf.exportInstanceDecT1(iw,iv,ic,ip,k,instanceType,solution,ratioQ,folderOut,instanceNumber)
    instanceNumber=instanceNumber+1

## INSTANCE ORDER GENERATION and param2.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,nTypes)
    
    #Exports 'param2.txt' with the required input for the task
    isf.exportTaskInfo(tN,bN,instanceOrder,nInstances,folderOut,i)