Ejemplo n.º 1
0
def CreateOuputFile(Algorithm,model,HV,PF,decisions,objectives,time):
    ##Print data for this Decision/objective pair
    print "----------------------------------------------------------------"
    fname = ('./data/'+model.__name__+'_'+str(decisions)+'Dec_and_'+str(objectives)+'Obj.txt')
    fo = open(fname, "wb")
    fo.write('Algorith : '+ Algorithm.__name__ + '\n')
    fo.write('Model    : '+ model.__name__ + '\n')
    fo.write('||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n')
    fo.write('HyperVolume of all Pareto Values Per Iteration\n')                    
    fo.write('||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n')
    fo.write('=====================================================================`\n')
    fo.write('Number of Decisions  = '+str(decisions) +'\n')
    fo.write('Number of Objectives = '+str(objectives) +'\n')
    fo.write('=====================================================================`\n')
    fo.write('HyperVolume Per Iteration\n')
    hvTable = PrettyTable()
    sNo = range(1,numOfIterations + 1)
    hvTable.add_column("Iteration  ",sNo)
    hvTable.add_column("HyperVolume",HV)
    #print hvTable
    fo.write( str(hvTable) + '\n' )
    fo.write('||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n')
    fo.write( '\nStart Time = ' +  time + '\n' ) 
    time = strftime("%Y-%m-%d %H:%M:%S", gmtime())
    fo.write( '\end Time = ' +  time + '\n' ) 
    fo.write('||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n')
    ##########
    
    #xTable  = PrettyTable()
    #fxTable = PrettyTable()
    #eTable  = PrettyTable()
    
    fo.close()  # Close opend file
Ejemplo n.º 2
0
def Dumpfile(paretoFront,stime):
    for i in range(len(paretoFront)):
        xTable = PrettyTable()
        sNo = range(1,paretoFront[i].N + 1)
        xTable.add_column("#",sNo)
        xTable.add_column("decisions, x",paretoFront[i].x)
        #print xTable
        fxTable = PrettyTable()
        sNo = range(1,paretoFront[i].objectives + 1)
        fxTable.add_column("#",sNo)
        fxTable.add_column("objectives,f(x)", paretoFront[i].fx)
        #print fxTable
        ## dump in file
        try:
            ouputRawFile.write( '________________________________\n' ) 
            ouputRawFile.write( 'paretoFrontier# :' + repr(i+1) + '\n' ) 
            ouputRawFile.write( 'objectives = ' +  repr(paretoFront[i].objectives) + '\n' )  # No of objectives f[0]f[1],f[2],...,f[M-1]
            ouputRawFile.write( 'decisions  = ' +  repr(paretoFront[i].decisions) + '\n' )   # decision variables  
            ouputRawFile.write( 'Energy     = ' +  repr(paretoFront[i].eval()) + '\n' )
            ouputRawFile.write( str(xTable) + '\n' )
            ouputRawFile.write( str(fxTable) + '\n' )
            #print "Successfully written in FILE: ",fname
        except:
            print "somthing went wrong while writting in FILE: ",fname
    time = strftime("%Y-%m-%d %H:%M:%S", gmtime())
    ouputRawFile.write( '_________Time Estimate___________\n' ) 
    ouputRawFile.write( 'Start Time = ' +  stime + '\n' )
    ouputRawFile.write( 'End Time   = ' +  time + '\n' )
    ouputRawFile.write( 'Number of values in paretoFrontier = ' + repr(len(paretoFront)) + '\n' )
    ouputRawFile.write( '_________________________________\n' ) 
    print "###########################################"
                #Print data for this Decision/objective pair
                print ""
                print "----------------------------------------------------------------"
                print "Finished processing ",model.__name__," with Decisions = ",decisions," and  Objectives = ",objectives
                fo.write('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n')
                fo.write('Finished processing '+str(model.__name__)+' with Decisions = '+repr(decisions)+' and  Objectives = '+repr(objectives)+'\n')
                fo.write('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n')
                print "List of Points in pareto Frontier in each iteration without tuning = ",len(PF)
                #print "HyperVolume      = ",HV
                print "List of Points in pareto Frontier in each iteration with tuning    = ",len(tunedPF)
                #print "Tuned HyperVolume= ",tunedHV             
                   
            ################
                #table print
                Table = PrettyTable()
                sNo = range(1,numOfIterations + 1)
                Table.add_column("Iteration  ",sNo)
                Table.add_column("Original Value",HV)
                Table.add_column("Tuned Value",tunedHV)
                print Table
                fo.write( str(Table) + '\n' )
                fo.write('||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n')
            
            ################
                ID1 = (model.__name__+' untuned   ')#+str(decisions)+'-Decisions '+str(objectives)+'-Objectives') 
                ID2 = (model.__name__+' tuned     ')#+str(decisions)+'-Decisions '+str(objectives)+'-Objectives') 


                rdivInput[rdivIndex].append(ID1)
                for each in HV:
Ejemplo n.º 4
0
def CreateOuputFile(Algorithm, model, HV, PF, decisions, objectives):
    ##Print data for this Decision/objective pair
    print "----------------------------------------------------------------"
    fname = "./data/" + model.__name__ + "_" + str(decisions) + "Dec_and_" + str(objectives) + "Obj.txt"
    fo = open(fname, "wb")
    fo.write("Algorith : " + Algorithm.__name__ + "\n")
    fo.write("Model    : " + model.__name__ + "\n")
    fo.write("||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n")
    fo.write("Decision,Objectives,Energy of all Pareto Values Per Iteration\n")
    fo.write("||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n")
    fo.write("=====================================================================`\n")
    fo.write("Number of Decisions  = " + str(decisions) + "\n")
    fo.write("Number of Objectives = " + str(objectives) + "\n")
    fo.write("=====================================================================`\n")
    fo.write("HyperVolume Per Iteration\n")
    hvTable = PrettyTable()
    sNo = range(1, numOfIterations + 1)
    hvTable.add_column("Iteration  ", sNo)
    hvTable.add_column("HyperVolume", HV)
    # print hvTable
    fo.write(str(hvTable) + "\n")
    fo.write("||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n")
    ##########

    xTable = PrettyTable()
    fxTable = PrettyTable()
    eTable = PrettyTable()

    count = 0
    for i in range(len(PF)):
        fo.write(
            "---------------------------------------------------------------------------------------------------------\n"
        )
        fo.write("ITERATION = " + str(i + 1) + "\n")
        fo.write(
            "---------------------------------------------------------------------------------------------------------\n"
        )

        for j in range(len(PF[i])):
            heading = "Dec, x    [ITERATION=" + str(i + 1) + "] [PF:" + str(j + 1) + "]"
            xTable.add_column(heading, PF[i][j].x)
            heading = "Obj, f(x) [ITERATION=" + str(i + 1) + "] [PF:" + str(j + 1) + "]"
            fxTable.add_column(heading, PF[i][j].getObjectives())
            heading = " Energy   [ITERATION=" + str(i + 1) + "] [PF:" + str(j + 1) + "]"
            val = [repr(PF[i][j].eval())]
            eTable.add_column(heading, val)
            count += 1
            if count == 3:
                count = 0
                # print xTable
                # print fxTable
                # print eTable
                fo.write("DECISIONS\n")
                fo.write(str(xTable) + "\n")
                fo.write("OBJECTIVES\n")
                fo.write(str(fxTable) + "\n")
                fo.write("ENERGY\n")
                fo.write(str(eTable) + "\n")
                fo.write(
                    "\n#########################################################################################################\n"
                )

                xTable = PrettyTable()
                fxTable = PrettyTable()
                eTable = PrettyTable()
        if count > 0:
            # print xTable
            # print fxTable
            # print eTable
            fo.write(str(xTable) + "\n")
            fo.write(str(fxTable) + "\n")
            fo.write(str(eTable) + "\n")

    fo.close()  # Close opend file