Skip to content

Model 1D…

July 10, 2011

Well, the problem with Model 1C turned out to be the selection of the worst offenders and best providers… I’ve changed that now, making it much simpler, and I get good results with these initial conditions. Now the worst offenders are all those whose income per hour is greater than the agents income per hour and the best providers are those whose incomer per hour is less than the agents income per hour. So in fact the names are no longer good. The agents base there decision upon who penalise or reward purely on jealousy and sympathy, at least until the decision of whether to change the investment pot or not, which is still based on how well the agents meet their demand. The full program is below, but first, here are the results after 5,000 iterations:

Model 1D:

       investmentpot = 500
        For i = 0 To 99
            demandtotal(i) = 0
            hours(i) = Int(Rnd() * 1000)
            income(i) = hours(i)
            For j = 0 To 99
                demand(i, j) = Int(Rnd() * 10)
                If i > 74 Then
                    demand(i, j) = Int(Rnd() * 5)
                End If
                demandtotal(i) = demandtotal(i) + demand(i, j)

            Next
        Next

        For k = 1 To 5000
            For i = 0 To 99
                If income(i) < demandtotal(i) Then
                    If hours(i) < demandtotal(i) Then
                        hours(i) = hours(i) + 1
                    End If
                    ' work more if income is not enough to meet agents demands
                Else
                    If hours(i) > 0 Then
                        hours(i) = hours(i) - 1
                    End If
                    ' work less if income is enough to meet agents demands
                End If
            Next

            For i = 0 To 99
                worstoffender = -1
                bestprovider = -1
                m = -1
                n = 0
                For j = 0 To 99
                    If (income(j) / hours(j)) > (income(i) / hours(i)) Then
                        m = m + 1
                        worstoffenders(m) = j
                    End If
                    If (income(j) / hours(j)) < (income(i) / hours(i)) Then
                        n = n + 1
                        bestproviders(n) = j
                    End If
                Next

                If m > -1 Then
                    worstoffender = worstoffenders(Int(Rnd() * m))
                    bestprovider = bestproviders(Int(Rnd() * n))
                    If (demandtotal(worstoffender) / hours(worstoffender)) > (demandtotal(i) / hours(i)) Or investmentpot = 0 Then
                        income(worstoffender) = income(worstoffender) - 1
                    Else
                        investmentpot = investmentpot - 1
                    End If
                    If (demandtotal(bestprovider) / hours(bestprovider)) < (demandtotal(i) / hours(i)) Then
                        income(bestprovider) = income(bestprovider) + 1
                    Else
                        investmentpot = investmentpot + 1
                    End If
                End If

            Next
        Next
Leave a Comment

Leave a comment