变量没有正确添加自己。的NetLogo

时间:2014-04-08 12:57:24

标签: netlogo

我一直致力于为飞行中的竞争航空公司建模。因此,我建模的代理商是乘客,我已经模拟了他们想要飞入的每个时间段的不同代理人。航空公司和机场的实际时段。这个想法是航空公司将改变他们的票价和时间表,根据他们以前的航班(迭代)在不同的时间飞行,以吸引最多的乘客或盈利。成本与他们想要飞入的时段有关(需求更高 - 成本更高)。我已经使用效用函数或多或少地模拟了乘客选择模型:

to flightchoice2

let potential-destinations out-link-neighbors

let best-patch max-one-of potential-destinations [utility-for1 myself]


ifelse random-float 1 > q 

[move-to best-patch][move-to one-of potential-destinations]


end  



to-report utility-for2 [businessman89] ;; Schedule Choice

let beta1 1

let beta2 1


let utility (beta1 * (1 / airfare) + beta2 * abs(time - time1))


report utility


end 

“(time-time1)基本上代表航空公司提供的服务与乘客想要的时间之间的时差。

我的问题来自于实际付款以便航空公司的营业额增加以及乘客的代理人被取消。我跟踪了一只羊狼模型,我已经到了摆脱乘客的地步,但是航空公司的营业额不会增加:“

to airfare-payment  ;; payment procedure


let customers1 business1-here      

if customers1 != nobody           

[ ask customers1 [ die ]             

set turnover turnover + airfare ] 



let customers2 business2-here     

 if customers2 != nobody             

[ ask customers2 [ die ]          

  set turnover turnover + airfare ] 



 let customers01 leisure1-here     

 if customers01 != nobody            

[ ask customers01 [ die ]            

  set turnover turnover + airfare ] 



  let customers02 leisure2-here   

 if customers02 != nobody           

[ ask customers02 [ die ]      

  set turnover turnover + airfare ] 



end

任何人都可以帮忙解释为什么航空公司的营业额没有正确增加?

编辑1-一个非常简化的版本,我的模型被上传以显示准确的问题

代理人已加载,从乘客到飞机的链接 Agents are Loaded, links are created to the airplanes from the passengers

飞机移动到他们的“出发时段”,由房屋代表,然后根据时间段和机票,乘客选择飞机

Airplanes move to their " departure time slots" which are represented by the houses, and then based on the time slot and airfare the passengers make their choice of airplane

从这个图中可以看出乘客被安置在飞机的同一位置,但是当[机票支付]程序运行时(前面描述过),不知何故,营业额没有正确加起来。 / p>

From this figure it is possible to see that the passengers are placed at the same position of the airplane, but when the [airfare-payment] procedure runs (described before), somehow the turnover doesn't add up correctly.

此图显示了在进入程序之前和之后的营业额计数,即使航空公司的营业额增加,也没有通过正确的计数进行。 This image shows the count of turnover before the go procedure and after, even though the turnover increases for the airlines it does not do so by the right count

我很确定问题来自创建代理时变量的设置方式。营业额设置为“乌龟自己”变量,机票被设置为每个航空公司的变量。

breed [business1 businessman78]  ;; business is its own plural, so we use "businessman" as the singular.
breed [business2 businessman89]

breed [Airline1 airplane1] 
breed [Airline2 airplane2]

breed [leisure1 leisureman78]
breed [leisure2 leisureman89]

breed [Runway1 r78] 
breed [Runway2 r89] 

airline1-own [ start-patch time1 airfare capacity turnover]
airline2-own [ start-patch time1 airfare capacity turnover] 
turtles-own [ time cost ]

然后在设置中创建飞机时设置机票和营业额的值。 A1的机票价格为100,而A2的票价为1000

1 个答案:

答案 0 :(得分:1)

此代码不正确:

let customers2 business2-here     
if customers2 != nobody

if条件始终为真,因为customers2是代理集,而nobody不是,所以它们永远不会彼此相等。 nobody表示缺少单一代理人;它不是一个空的代理集。

(想想就这样:因为我没有苹果,这并不意味着我有一个空的苹果袋。我可能什么也没有,甚至没有包。)

我认为你的意思是:

let customers2 business2-here
if any? customers2

我不知道这是否是 你的错误原因,但无论如何,你都想修复它。