Пример #1
0
def randomSimulation():
	numOfTraderss = range(100, 1000, 100)
	numOfUnitsPerTraders = range(1, 10, 1)
	meanValue = 500
	maxNoiseSizes = range(50, 500, 50)
	numOfAuctions = 10
	filenameTraders = "results/random-traders-{}units-{}noise.csv".format(numOfUnitsPerTraders[-1],maxNoiseSizes[-1])
	filenameUnits   = "results/random-units-{}traders-{}noise.csv".format(numOfTraderss[-1],maxNoiseSizes[-1])
	filenameNoise   = "results/random-noise-{}traders-{}units.csv".format(numOfTraderss[-1],numOfUnitsPerTraders[-1])
	filenameTradersAdd = "results/random-traders-{}units-{}noise-additive.csv".format(numOfUnitsPerTraders[-1],maxNoiseSizes[-1])
	filenameUnitsAdd   = "results/random-units-{}traders-{}noise-additive.csv".format(numOfTraderss[-1],maxNoiseSizes[-1])
	filenameNoiseAdd   = "results/random-noise-{}traders-{}units-additive.csv".format(numOfTraderss[-1],numOfUnitsPerTraders[-1])
	if createResults:
		simulateAuctions(randomAuctions(
			numOfAuctions, numOfTraderss, numOfUnitsPerTraders[-1:], meanValue, maxNoiseSizes[-1:]),
			filenameTraders)
		simulateAuctions(randomAuctions(
			numOfAuctions, numOfTraderss[-1:], numOfUnitsPerTraders, meanValue, maxNoiseSizes[-1:]),
			filenameUnits)
		simulateAuctions(randomAuctions(
			numOfAuctions, numOfTraderss[-1:], numOfUnitsPerTraders[-1:], meanValue, maxNoiseSizes),
			filenameNoise)
		simulateAuctions(randomAuctions(
			numOfAuctions, numOfTraderss, numOfUnitsPerTraders[-1:], meanValue, maxNoiseSizes[-1:],isAdditive=True),
			filenameTradersAdd)
		simulateAuctions(randomAuctions(
			numOfAuctions, numOfTraderss[-1:], numOfUnitsPerTraders, meanValue, maxNoiseSizes[-1:],isAdditive=True),
			filenameUnitsAdd)
		simulateAuctions(randomAuctions(
			numOfAuctions, numOfTraderss[-1:], numOfUnitsPerTraders[-1:], meanValue, maxNoiseSizes,isAdditive=True),
			filenameNoiseAdd)
	plotRandom(filenameTraders,"Optimal units",numOfAuctions)
	plotRandom(filenameUnits,"Max units per trader",numOfAuctions)
	plotRandom(filenameNoise,"Optimal units",numOfAuctions)
	plotRandom(filenameTradersAdd,"Optimal units",numOfAuctions)
	plotRandom(filenameUnitsAdd,"Max units per trader",numOfAuctions)
	plotRandom(filenameNoiseAdd,"Optimal units",numOfAuctions)
def randomSimulation():
    numOfTraderss = range(20000, 420000, 20000)
    numOfUnitsPerTraders = [1, 10, 100, 10000, 100000, 1000000, 1000]
    meanValue = 500
    maxNoiseSizes = [50, 100, 150, 200, 300, 350, 400, 450, 500, 250]
    numOfAuctions = 10
    filenameTraders = "results/random-traders-{}units-{}noise.csv".format(
        numOfUnitsPerTraders[-1], maxNoiseSizes[-1])
    filenameUnitsFixedTraders = "results/random-units-{}traders-{}noise.csv".format(
        numOfTraderss[-1], maxNoiseSizes[-1])
    filenameUnitsFixedVirtual = "results/random-units-{}virtual-{}noise.csv".format(
        numOfTraderss[-1], maxNoiseSizes[-1])
    filenameNoise = "results/random-noise-{}traders-{}units.csv".format(
        numOfTraderss[-1], numOfUnitsPerTraders[-1])
    # filenameTradersAdd = "results/random-traders-{}units-{}noise-additive.csv".format(numOfUnitsPerTraders[-1],maxNoiseSizes[-1])
    # filenameUnitsAdd   = "results/random-units-{}traders-{}noise-additive.csv".format(numOfTraderss[-1],maxNoiseSizes[-1])
    # filenameNoiseAdd   = "results/random-noise-{}traders-{}units-additive.csv".format(numOfTraderss[-1],numOfUnitsPerTraders[-1])
    if createResults:
        keyColumns = ("numOfTraders", "numOfUnitsPerTrader", "maxNoiseSize",
                      "isAdditive")
        # simulateAuctions(randomAuctions(
        # 	numOfAuctions, numOfTraderss, numOfUnitsPerTraders[-1:], meanValue, maxNoiseSizes[-1:], isAdditive=False, fixedNumOfVirtualTraders=True),
        # 	filenameTraders, keyColumns=keyColumns)
        # simulateAuctions(randomAuctions(
        # 	numOfAuctions, numOfTraderss[-1:], numOfUnitsPerTraders, meanValue, maxNoiseSizes[-1:], isAdditive=False, fixedNumOfVirtualTraders=True),
        # 	filenameUnitsFixedVirtual, keyColumns=keyColumns)
        simulateAuctions(randomAuctions(numOfAuctions, [100],
                                        numOfUnitsPerTraders,
                                        meanValue,
                                        maxNoiseSizes[-1:],
                                        isAdditive=False,
                                        fixedNumOfVirtualTraders=False),
                         filenameUnitsFixedTraders,
                         keyColumns=keyColumns)
        simulateAuctions(randomAuctions(numOfAuctions,
                                        numOfTraderss[-1:],
                                        numOfUnitsPerTraders[-1:],
                                        meanValue,
                                        maxNoiseSizes,
                                        isAdditive=False,
                                        fixedNumOfVirtualTraders=True),
                         filenameNoise,
                         keyColumns=keyColumns)
        # simulateAuctions(randomAuctions(
        # 	numOfAuctions, numOfTraderss, numOfUnitsPerTraders[-1:], meanValue, maxNoiseSizes[-1:],isAdditive=True, fixedNumOfVirtualTraders=True),
        # 	filenameTradersAdd, keyColumns=keyColumns)
        # simulateAuctions(randomAuctions(
        # 	numOfAuctions, numOfTraderss[-1:], numOfUnitsPerTraders, meanValue, maxNoiseSizes[-1:],isAdditive=True, fixedNumOfVirtualTraders=True),
        # 	filenameUnitsAdd, keyColumns=keyColumns)
        # simulateAuctions(randomAuctions(
        # 	numOfAuctions, numOfTraderss[-1:], numOfUnitsPerTraders[-1:], meanValue, maxNoiseSizes,isAdditive=True, fixedNumOfVirtualTraders=True),
        # 	filenameNoiseAdd, keyColumns=keyColumns)
    numOfBins = 10
    plotRandom(filenameTraders,
               "numOfTraders",
               numOfBins,
               plt.subplot(1, 1, 1),
               title="m={}, noise={}".format(numOfUnitsPerTraders[-1],
                                             maxNoiseSizes[-1]))
    # plt.ylabel(YLABEL); plt.xlabel('')
    plt.show()
    # plotRandom(filenameTraders,"Optimal units",numOfBins, plt.subplot(2,4,2),
    # 	title="m={}, noise={}".format(numOfUnitsPerTraders[-1],maxNoiseSizes[-1]))
    # plt.ylabel(''); plt.xlabel('')
    # plt.show()
    plotRandom(filenameUnitsFixedVirtual,
               "numOfUnitsPerTrader",
               numOfBins,
               plt.subplot(1, 1, 1),
               title="total units={}, noise={}".format(numOfTraderss[-1],
                                                       maxNoiseSizes[-1]))
    # plt.ylabel(''); plt.xlabel('')
    plt.show()
    plotRandom(filenameUnitsFixedTraders,
               "numOfUnitsPerTrader",
               numOfBins,
               plt.subplot(1, 1, 1),
               title="traders={}, noise={}".format(numOfTraderss[-1],
                                                   maxNoiseSizes[-1]))
    # plt.ylabel(''); plt.xlabel('')
    plt.show()
    plotRandom(filenameNoise,
               "maxNoiseSize",
               numOfBins,
               plt.subplot(1, 1, 1),
               title="traders={}, m={}".format(numOfTraderss[-1],
                                               numOfUnitsPerTraders[-1]))
    # plt.ylabel(''); plt.xlabel('')
    plt.show()
Пример #3
0
def randomSimulation(numOfAuctions=100):
    numOfTraderss = range(2000000, 42000000, 2000000)  #range(200,4200,200) #
    minNumOfUnitsPerTrader = 1  # 10
    maxNumOfUnitsPerTraders = [
        100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 10
    ]
    meanValue = 500
    maxNoiseSizes = [50, 100, 150, 200, 300, 350, 400, 450, 500, 250]
    numOfBins = 20

    # general
    filenameTraders = "results/random-traders-{}units-{}noise.csv".format(
        maxNumOfUnitsPerTraders[-1], maxNoiseSizes[-1])
    filenameUnitsFixedTraders = "results/random-units-{}traders-{}noise.csv".format(
        numOfTraderss[-1], maxNoiseSizes[-1])
    filenameUnitsFixedVirtual = "results/random-units-{}virtual-{}noise.csv".format(
        numOfTraderss[-1], maxNoiseSizes[-1])
    filenameNoise = "results/random-noise-{}traders-{}units.csv".format(
        numOfTraderss[-1], maxNumOfUnitsPerTraders[3])

    # additive
    filenameTradersAdd = "results/random-traders-{}units-{}noise-additive.csv".format(
        maxNumOfUnitsPerTraders[3], maxNoiseSizes[-1])
    filenameUnitsAdd = "results/random-units-{}traders-{}noise-additive.csv".format(
        numOfTraderss[-1], maxNoiseSizes[-1])
    filenameNoiseAdd = "results/random-noise-{}traders-{}units-additive.csv".format(
        numOfTraderss[-1], maxNumOfUnitsPerTraders[3])
    if createResults:
        keyColumns = ("numOfTraders", "minNumOfUnitsPerTrader",
                      "maxNumOfUnitsPerTrader", "maxNoiseSize")

        ### non-additive
        simulateAuctions(
            randomAuctions(  ### as function of #traders
                numOfAuctions,
                numOfTraderss,
                minNumOfUnitsPerTrader,
                maxNumOfUnitsPerTraders[-1:],
                meanValue,
                maxNoiseSizes[-1:],
                fixedNumOfVirtualTraders=True),
            filenameTraders,
            keyColumns=keyColumns)
        simulateAuctions(
            randomAuctions(  ### as function of m - fixed total units
                numOfAuctions,
                numOfTraderss[-1:],
                minNumOfUnitsPerTrader,
                maxNumOfUnitsPerTraders,
                meanValue,
                maxNoiseSizes[-1:],
                fixedNumOfVirtualTraders=True),
            filenameUnitsFixedVirtual,
            keyColumns=keyColumns)

    TITLESTART = ""
    ### non-additive
    ax = plt.subplot(1, 2, 1)
    plotResults(
        filenameTraders,
        "Total traders",
        numOfBins,
        ax,
        title=TITLESTART +
        "Fixed units per trader, M={}".format(maxNumOfUnitsPerTraders[-1]))
    ax.set_xlabel('Total #traders', fontsize=axesFontSize)

    ax = plt.subplot(1, 2, 2, sharey=None)
    plotResults(filenameUnitsFixedVirtual,
                "log10(M)",
                numOfBins=None,
                ax=ax,
                title=TITLESTART +
                "Fixed total units, M*n={}".format(numOfTraderss[-1]))
    ax.set_xlim([1, 8])
    ax.set_xticklabels(["", "100", "1e3", "1e4", "1e5", "1e6", "1e7", "1e8"])
    ax.set_xlabel('Max #units per trader (M)', fontsize=axesFontSize)
    ax.set_ylabel("")

    plt.show()
Пример #4
0
def randomSimulation(numOfAuctions=100):
    numOfTraderss = range(2000000, 42000000, 2000000)
    minNumOfUnitsPerTrader = 10
    maxNumOfUnitsPerTraders = [
        100, 1000, 10000, 1000000, 10000000, 100000000, 100000
    ]
    meanValue = 500
    maxNoiseSizes = [50, 100, 150, 200, 300, 350, 400, 450, 500, 250]
    numOfBins = 20

    # general
    filenameTraders = "results/random-traders-{}units-{}noise.csv".format(
        maxNumOfUnitsPerTraders[-1], maxNoiseSizes[-1])
    filenameUnitsFixedTraders = "results/random-units-{}traders-{}noise.csv".format(
        numOfTraderss[-1], maxNoiseSizes[-1])
    filenameUnitsFixedVirtual = "results/random-units-{}virtual-{}noise.csv".format(
        numOfTraderss[-1], maxNoiseSizes[-1])
    filenameNoise = "results/random-noise-{}traders-{}units.csv".format(
        numOfTraderss[-1], maxNumOfUnitsPerTraders[3])

    # additive
    filenameTradersAdd = "results/random-traders-{}units-{}noise-additive.csv".format(
        maxNumOfUnitsPerTraders[3], maxNoiseSizes[-1])
    filenameUnitsAdd = "results/random-units-{}traders-{}noise-additive.csv".format(
        numOfTraderss[-1], maxNoiseSizes[-1])
    filenameNoiseAdd = "results/random-noise-{}traders-{}units-additive.csv".format(
        numOfTraderss[-1], maxNumOfUnitsPerTraders[3])
    if createResults:
        keyColumns = ("numOfTraders", "minNumOfUnitsPerTrader",
                      "maxNumOfUnitsPerTrader", "maxNoiseSize")

        ### non-additive
        simulateAuctions(
            randomAuctions(  ### as function of #traders
                numOfAuctions,
                numOfTraderss,
                minNumOfUnitsPerTrader,
                maxNumOfUnitsPerTraders[-1:],
                meanValue,
                maxNoiseSizes[-1:],
                fixedNumOfVirtualTraders=True),
            filenameTraders,
            keyColumns=keyColumns)
        simulateAuctions(
            randomAuctions(  ### as function of m - fixed total units
                numOfAuctions,
                numOfTraderss[-1:],
                minNumOfUnitsPerTrader,
                maxNumOfUnitsPerTraders,
                meanValue,
                maxNoiseSizes[-1:],
                fixedNumOfVirtualTraders=True),
            filenameUnitsFixedVirtual,
            keyColumns=keyColumns)
        # simulateAuctions(randomAuctions(   ### as function of m - fixed total traders - TOO LONG
        # 	numOfAuctions, [100], minNumOfUnitsPerTrader, maxNumOfUnitsPerTraders, meanValue, maxNoiseSizes[-1:], fixedNumOfVirtualTraders=False),
        # 	filenameUnitsFixedTraders, keyColumns=keyColumns)
        simulateAuctions(
            randomAuctions(  ### as function of noise
                numOfAuctions,
                numOfTraderss[-1:],
                minNumOfUnitsPerTrader,
                maxNumOfUnitsPerTraders[-1:],
                meanValue,
                maxNoiseSizes,
                fixedNumOfVirtualTraders=True),
            filenameNoise,
            keyColumns=keyColumns)

        ### additive
        # simulateAuctions(randomAuctions(  ### as function of #traders
        # 	numOfAuctions, numOfTraderss, maxNumOfUnitsPerTraders[3], maxNumOfUnitsPerTraders[-1:], meanValue, maxNoiseSizes[-1:], fixedNumOfVirtualTraders=True),
        # 	filenameTradersAdd, keyColumns=keyColumns)
        # # simulateAuctions(randomAuctions(   ### as function of m - fixed total units
        # # 	numOfAuctions, numOfTraderss[-1:], maxNumOfUnitsPerTraders, meanValue, maxNoiseSizes[-1:],isAdditive=True, fixedNumOfVirtualTraders=True),
        # # 	filenameUnitsAdd, keyColumns=keyColumns)
        # simulateAuctions(randomAuctions(    ### as function of noise
        # 	numOfAuctions, numOfTraderss[-1:],  maxNumOfUnitsPerTraders[3], maxNumOfUnitsPerTraders[-1:], meanValue, maxNoiseSizes, fixedNumOfVirtualTraders=True),
        # 	filenameNoiseAdd, keyColumns=keyColumns)
        # # simulateAuctions(randomAuctions(   ### as function of m - fixed total traders
        # # 	numOfAuctions, [100], maxNumOfUnitsPerTraders, meanValue, maxNoiseSizes[-1:], isAdditive=True, fixedNumOfVirtualTraders=False),
        # # 	filenameUnitsFixedTraders, keyColumns=keyColumns)

    TITLESTART = ""  # "Uniform; "
    ### non-additive
    ax = plt.subplot(1, 2, 1)
    plotResults(filenameTraders,
                "Total traders",
                numOfBins,
                ax,
                title=TITLESTART + "m={},M={},noise={}".format(
                    minNumOfUnitsPerTrader, maxNumOfUnitsPerTraders[-1],
                    maxNoiseSizes[-1]))
    ax.set_xlabel('Total #traders', fontsize=axesFontSize)
    ax.set_xlim([0, 1000])

    # ax=plt.subplot(1,1,1)
    # plotResults(filenameTraders,"Optimal units",numOfBins, ax, title=
    #	TITLESTART+"m={},M={},noise={}".format(minNumOfUnitsPerTrader,maxNumOfUnitsPerTraders[3],maxNoiseSizes[-1]))
    # plt.xlabel('Optimal #units (k)')
    # plt.show()

    ax = plt.subplot(1, 2, 2, sharey=None)
    plotResults(
        filenameUnitsFixedVirtual,
        "log10(M)",
        numOfBins=None,
        ax=ax,
        title=TITLESTART + "m={},units={},noise={}".format(
            minNumOfUnitsPerTrader, numOfTraderss[-1], maxNoiseSizes[-1]))
    #labels = [""]+["{:.0e}".format(t) for t in sorted(maxNumOfUnitsPerTraders)]
    ax.set_xlim([1, 8])
    ax.set_xticklabels(["", "100", "1e3", "1e4", "1e5", "1e6", "1e7", "1e8"])
    ax.set_xlabel('Max #units per trader (M)', fontsize=axesFontSize)
    ax.set_ylabel("")

    plt.show()