1
我有4個生產者具有不同的屬性,如他們的新產品的價格,大小,客戶費率。我定義了4個代表它們的列表。更新netlogo中的列表中的項目的值
set att-price ((list p1-pr p2-pr p3-pr p4-pr))
;的4個生產者
set att-size ((list p1-sz p2-sz p3-sz p4-sz))
set att-rates ((list p1-rt p2-rt p3-rt p4-rt))
隨着時間的推移,價格獲取更新的所有產品的價格,所以我定義這個要做到這一點:
set (item 0 att-price) (item 0 att-price) * 0.20
;生產者的產品價格的變化
set (item 1 att-price) (item 1 att-price) * 0.08
set (item 3 att-price) (item 3 att-price) * 0.43
但它有一個錯誤說「這不是你可以」設置「上」!
那麼我該如何更新這些項目呢? 謝謝
謝謝。我用'set att-price replace-item 0(0.2 * item 0 att-price)att-price'來代替'set(item 0 att-price)(item 0 att-price)* 0.20',但是發現一個錯誤說「替換項目」預計這個輸入是一個字符串或列表,但得到一個數字。 – user710
@ user710新值最後一位: https://ccl.northwestern.edu/netlogo/docs/dictionary.html#replace-item – Alan
非常感謝Alan。是的,通過設置att-price replace-item 0 att-price(0.2 * item 0 att-price)',它工作得很好:) – user710