Reputation: 149
I have to code a SELLERS-BUYERS model in Netlogo. And some parts of it I have already done. But there some troubles with calculating of "deal price" and some other processes. The problem is that I dont know the programm language of Netlogo so well that to code all of the model.
I have to settle a deal_Price between seller and buyer and they have to be in one patch. Every seller has its ownCosts and every buyer has its ownUtility. When the seller_Price = buyer_Price they have deal_Price. And this deal_Price has to be below ownUtility of the buyer and above of ownCosts of the seller (which are in the same patch). And all of this happens in "interaction" process.
i code it so:
to interaction
ask sellers [
set seller_Price 0]
ask buyers [
set buyer_Price 0]
ask buyers [
if buyer_Price > ownUtility [
set buyer_Price buyer_Price < ownUtility ]]
ask sellers [
if seller_Price < ownCosts [
set seller_Price seller_Price > ownCosts ]]
end
For the result buyer and seller ( who are in the same patch) have to deal. And I tried to code "deal" process so:
to deal
if thera buyer and seller in one patch (its probably false)
ask buyers [
set ownUtility ownUtility + (buyer_Price - deal_Price)]
ask sellers [
set ownCosts ownCosts + (seller_Price - deal_Price) ]
end
Here have I problems, because with this codes my model has no result and it doesnt run. Could anyone help me?
Upvotes: 2
Views: 394
Reputation: 30498
This isn't really a single question, but a bunch of questions in one. I'll try to say a few helpful things that address at least some of the issues you're facing, but in the future, it's really better if you ask specific questions and ask them separately. You'll know it's a good question if you can summarize it in a single sentence. If your summary ends up being "help me code this", it's probably not really a question.
set buyer_Price buyer_Price < ownUtility
will set buyer_price
to either true
or false
, depending on the result of the comparison. I don't think that's what you intended; you probably intended to set it to a number. I can't tell from your question what number you want, though. You write, “And this deal_Price has to be below ownUtility of the buyer and above of ownCosts of the seller”. Do you want a random number in that range, or what?
As for your deal
procedure, dr_stein covered this in his or her comment, but, perhaps you want something like this:
to deal
ask patches with [any? buyers-here and any? sellers-here] [
ask buyers-here [
set ownUtility ownUtility + (buyer_Price - deal_Price)
]
ask sellers-here [
set ownCosts ownCosts + (seller_Price - deal_Price)
]
]
end
that isn't complete because it doesn't contain any code which computes deal_Price
, but hopefully you can supply that part yourself.
Finally, some more general advice. You may be trying to learn too much all at once by writing a big program all at once. Write a really small program; get it working; attempt to make a very small improvement to it, and get that working; and so on. If at any point you get stuck, come here, show your code, and ask a specific question about it.
Upvotes: 1