Reputation: 25
Greeting,
let assume, I have one manufacture and 10 customers that manufacture create links with some of them randomly(I call these links "contract-links").
One of the properties of manufacture is "real-cost" and one of the properties of customers is "real-waiting-time". "real-waiting-time" is a clear number. Also, Assume service-cost as a global variable.
To calculate the "real-cost", I need the sum of "real-waiting-time" of customers who have links with the manufacture and then multiply in service cost.
I have a question here to calculate "real-cost". How can I call the "real-waiting-time" of all customers and then calculate the real-cost for manufacture?
manufactures-own [ final-costs]
customers-costs [ real-waiting-time]
contract-links [ the-real]
ask manufactures [
final-calculation-for-manufacture
]
to final-calculation-for-manufacture
let the-manufacture self
let the-contract my-contract-links
ask my-contract-links [
set the-real [real-waiting-time] of end2
]
let the-sum sum [ the-real] of my-contract-links
set final-cost the-sum * cost-service-slider
end
It gives me a number, but the answer is wrong.
Upvotes: 1
Views: 78
Reputation: 17678
I think the reason that you are getting the wrong number is that you are doing a lot of setting of the attribute values at the other end of the links instead of getting the information from that link. But your general approach is too complicated - if you have created a link breed called contract-links
(which you seem to have), then the agents at the other ends of those links are the link neighbors of agent asking. Try something like this.
manufactures-own [ final-costs]
customers-costs [ real-waiting-time]
contract-links [ the-real]
ask manufactures
[ let the-sum final-costs sum [real-waiting-time] of contract-links-neighbors
set final-cost the-sum * cost-service-slider
]
end
This assumes you want the sum of the waiting times of the linked customers. I couldn't work out what the attribute the-real
is for the links.
Upvotes: 1