Indirect allocation of resources than intended

19 views
Skip to first unread message

Aruho Tinka

unread,
Jan 8, 2025, 6:38:48 AMJan 8
to netlogo-users
Dear Users,
I need help with my procedure (and code) that allocates, which is not the intention, more resources (income) whenever more than one operator is generated. 
The idea and intention is that one owner is linked to one operator, and is paid a percentage share of net-fare collections, accounted as my-pay. This is accumulated as operators' income over time. The owner will receive a pre-specified remittance and any other remaining collections (termed under-declaration) if it is there.  

to remit-CFC-target-fee-and-get-paid  ;;called by the operator
   if ticks mod 720 = 0 [
   
;reset for the next cycle
    set Operators-Income 0
    ask Veh-Owners[set Owners-Income 0]
   
    setxy start-x start-y   ; reset position to the original so a remittance can be made to
                            ;the vehicle owner

    ; Create a list of operator-owner pairs
    let operator-owner-pairs []
    ask Operators [
    let my-Veh-Owner one-of link-neighbors with [breed = Veh-Owners]
    if my-Veh-Owner != nobody [
      set operator-owner-pairs lput (list self my-Veh-Owner) operator-owner-pairs
    ]
  ]
    ; Iterate through each pair using foreach
  foreach operator-owner-pairs [pair ->
    let operator1 item 0 pair
    let owner1 item 1 pair
     
       ask operator1 [    
     
     ;;remove operating costs from total collections
       set CFC-net-fare-collections CFC-total-fare-collections - Operator-costs
           
        set my-pay Operator-pay-perc * CFC-net-fare-collections ;;this is the operators pay
                                                                 
      set under-declaration  max list 0 (CFC-net-fare-collections - remittance - my-pay)  

      ;;operators receive their pay and update their incomes with the "my-pay"
     
      set Operators-Income Operators-Income + my-pay
      set CFC-net-fare-collections CFC-net-fare-collections - my-pay
      ]
     
     ;;pay the vehicle owner
        ifelse CFC-net-fare-collections  >= remittance  + under-declaration  [
         ask owner1 [
        let VO-share-above-target [under-declaration] of myself
        set actual-received   [remittance] of myself + VO-share-above-target    
        set Owners-Income Owners-Income + actual-received
       ]
      ]
    ;;in case net-fare collection is below sum of remittance and underdeclaration, ;;the owner takes it as what is available.

      [ask owner1 [set Owners-Income Owners-Income + CFC-net-fare-collections    
       
      ]
      ]
     ]
end

I thank you.

Aruho
Reply all
Reply to author
Forward
0 new messages