使用NetLogo查找多个最小值

时间:2021-06-30 22:49:37

I have two breeds; firms and consumers. My consumers apply to random n of firms, and then firms select the consumers who have the lowest wage demand.

我有两个品种;公司和消费者。我的消费者适用于随机的公司,然后公司选择工资要求最低的消费者。

Firms have a labor demand, consumers have a wage-rate, each labor demand and wage rate is firms and consumer specific.

企业有劳动力需求,消费者有工资率,每个劳动力需求和工资率都是企业和消费者的具体情况。

Labor demand can be more then applicant to a firm. I want to choose the minimum count of those two agent set, and make my worker-set's count accordingly.

劳动力需求可能比申请企业更多。我想选择这两个代理集的最小计数,并相应地使我的工人集计数。

to select-workers ; firm specific action
  ask consumers [ set occupational-status 0] ; I'm setting every consumer/workers unemployed at the beginning
    set applicants no-turtles ; i have an applicant agent set representing applied consumers to work
    set worker-set no-turtles ; i have an worker-set which will turn in to an agent set holding my workers
  ask consumers [ ask n-of M firms [ set applicants (turtle-set myself applicants)   ; i have constructed my agent set
    let appl-count count applicants
    let demand-count count laborDemand
    let myList ( list appl-count demand-count )
] 

end

My problem begins at the end of the code, I want to transfer my applicants to my worker-set but if applicant count is less than my labor demand, program does not work properly. Also I should choose consumers with the lowest minimum wage.

我的问题始于代码的末尾,我想将我的申请人转移到我的工人集,但如果申请人数量少于我的劳动力需求,则程序无法正常运行。我也应该选择最低工资最低的消费者。

Thanks in advance

提前致谢

1 个解决方案

#1


You can use foreach. It's not pretty but it can work... something like

你可以使用foreach。它不漂亮,但它可以工作...类似的东西

  let list_value [my_value] of citizens
  set list_value sort-by > list_value
  let nb_nomination [1 1] ;;of repetitions
  foreach nb_nomination [
     ask one-of citizens with[my_value = first list_value][
       set happy TRUE
     ]
   set list_value but-first list_value
   ]

#1


You can use foreach. It's not pretty but it can work... something like

你可以使用foreach。它不漂亮,但它可以工作...类似的东西

  let list_value [my_value] of citizens
  set list_value sort-by > list_value
  let nb_nomination [1 1] ;;of repetitions
  foreach nb_nomination [
     ask one-of citizens with[my_value = first list_value][
       set happy TRUE
     ]
   set list_value but-first list_value
   ]