Dear colleagues,
I seek your assistance in correcting my code which is not performing as expected - the 'Operators-Income' accumulation seems astronomical more than
The Operator gathers fare collections into "total-trip-collection", from which he pays the rent for the vehicle as "remittance", and "Operator-costs". If they gather enough to cover these two expenses, they pay themselves with the balance. If they dont gather enough, they meet "Operator-costs" and pay the remainder to the vehicle owner and go without anything.
ask Operators with [any? link-neighbors with [breed = Veh-Owners]] [
if job? = True and ( ticks = operating-time or ticks mod 720 = 0) and dismissed-tracker <= 3 [remit-target-fee take-balance]
to remit-target-fee
If ticks mod 720 = 0 [
setxy start-x start-y
set actual-collect total-trip-collection - Operator-costs
let my-Veh-Owner one-of link-neighbors with [ breed = Veh-Owners]
ifelse actual-collect >= remittance [
ask my-Veh-Owner [
set actual-received [remittance] of myself
set Owners-Income Owners-Income + actual-received]
set distance-traveled 0
set Operator-costs 0
set operating-time 0
] [
let actual-remittance actual-collect
ask my-Veh-Owner [
set actual-received [actual-remittance] of myself
set Owners-Income Owners-Income + actual-received]
set Owner-link nobody
ask my-links [die]
]
]
end
to take-balance
if ticks mod 720 = 0 [if actual-collect >= remittance [
set my-pay actual-collect - remittance
set Operators-Income Operators-Income + my-pay]
if my-pay < 0 [
set my-pay 0
]
set total-trip-collection 0]
end
Thank you