Модель NetLogo о принятии решения о размещении производства ведет к экспоненциальному росту - PullRequest
1 голос
/ 08 мая 2019

Я создал модель, с помощью которой я пытаюсь воспроизвести явление автоматизации, вызванное повторным производством.1. У меня есть особая проблема: экспоненциальный рост капитала фирм приводит к краху симуляции в один момент, поскольку NetLogo не может справиться с такими большими числами.2. Решение о местонахождении производства зависит от сравнения между тем, сколько может быть получено прибыли на дому и прибыли за рубежом.В зависимости от того, какие из них ниже, фирмы должны двигаться либо на «глобальный север», либо на «глобальный юг».На данный момент они перемещаются только на север, независимо от того, какой у меня параметр.

Я просто не могу найти здесь свою ошибку в мысли.Кто-нибудь?Большое спасибо уже заранее.

breed [ firms firm ]   ;; defines agentset and agents

globals [   ;; general parameters accessible by all agents from all across the world
  labour-unit   ;; either low-, high-skilled labour or robots
  high-skilled-labour-ratio ]   ;; defined through low-skilled-labour-ratio slider as the ratio of labour needs to be 1 in sum


firms-own [   ;; parameters belonging to agents only
  firm-size   ;; divides the firms by size according to their capital
  output    ;; amount of products produced (in units)
  max-level-of-automation    ;; maximal level of efficiency in automation for the specific product line of each firm
  labour-units-at-home   ;; number of workers employed at home
  labour-units-abroad   ;; number of workers employed abroad
  level-of-automation    ;; current efficiency in automation
  actual-low-skilled-labour-ratio   ;; defines the ratio of low-skilled in proportion to high-skilled labour and automation
  actual-high-skilled-labour-ratio   ;; defines the ratio of low-skilled in proportion to high-skilled labour and automation
  robots   ;; number of robots utilised for production
  low-skilled-labour   ;; number of low-skilled-workers (in number of persons) ASSUMPTION: Unlimited availability of low-skilled workers on the labour market
  high-skilled-labour   ;; number of high-skilled-workers (in number of persons) ASSUMPTION: Unlimited availability of high-skilled workers on the labour market
  raw-material-costs   ;; fix costs for raw materials
  budget-for-labour-costs   ;; planned budget available for paying labour wages
  actual-labour-costs   ;; actual budget spent on labour wages
  automation-costs   ;; costs for maintaining and running automated production (e.g. energy costs)
  capital   ;; assumed to be equal to the output (in €)
  revenue   ;; output multiplied by the price per product (in €)
  profit-at-home   ;; revenue minus R&D investment
  profit-abroad   ;; revenue minus R&D investment and foreign surcharges
  r&d-investment   ;; particular share of capital invested in R&D
  foreign-surcharges   ;; additional costs for firms producing abroad such as shipping costs or import tariffs
  relocation-costs   ;; share of profit which would be needed to relocate production
  offshored?   ;; true or false
  reshored?   ;; true or false
  relocated?   ;; true or false
]


to setup
  clear-all   ;; resets all global variables to zero
  clear-all-plots   ;; clears every plot in the model
  setup-economy   ;; create the world division in Germany and the producer countries in the global South
  setup-industry   ;; create the industry
  reset-ticks   ;; resets the tick counter to zero
end


to setup-economy   ;; sets up the geography of the model
  create-firms number-of-firms   ;; number of firms to be defined through slider
  ask patches with [ pycor > 0 ] [
    set pcolor 98 ]   ;; colours Germany in a shade of blue
  ask patches with [ pycor = 0 ] [
    set pcolor white ]   ;; colours the equator white
  ask patches with [ pycor < 0 ] [
  set pcolor 48 ]   ;; colours producing countries in the global South in a shade of yellow
end


to setup-industry   ;; sets up the economy of the model
  setup-firms   ;; see auxiliary code below
  offshoring   ;; defines the amount of firms which have decided to offshore in the past
  state-of-the-art   ;; see auxiliary code below
  costs-calculation   ;; see auxiliary code below
  labour-automation-ratio   ;; see auxiliary code below
  employment   ;; see auxiliary code below
  output-calculation   ;; see auxiliary code below
  revenue-calculation   ;; see auxiliary code below
  r&d-calculation   ;; see auxiliary code below
  profit-calculation   ;; see auxiliary code below
  firms-size-ratio   ;; see auxiliary code below
end


to go   ;; let's go...!!
  tick   ;; advances the tick counter by one
  ask firms [
    ifelse ( offshored? = false ) [
      set capital capital + profit-at-home ] [   ;; sum of the capital and profit (values from the previous time period)
      set capital capital + profit-abroad ] ]
  technological-progress   ;; see auxiliary code below
  costs-calculation
  labour-automation-ratio
  employment
  output-calculation
  revenue-calculation
  r&d-calculation
  profit-calculation
  location-decision   ;; see auxiliary code below
  firms-size-ratio
  bankruptcy
  if ticks = 500 [ stop ]   ;; makes the modell run the same length each simulation
end


to-report random-between [ min-num max-num ]   ;; auxiliary code
   report random-float (max-num - min-num) + min-num
end


to setup-firms   ;; auxiliary code: initial configuration of firms
  ask firms [
    set capital random 1000
    set max-level-of-automation 0 + random-float 1   ;; random between >0 and <1 and will stay fix, because it is unrealistic that it'll be technologically feasible to automise production of all products equally
    set level-of-automation 0 ]   ;; initially all firms have a random output
end


to offshoring   ;; auxiliary code: when it is less likely to automate the product line, the higher the incentive to offshore where manual labour is cheaper
  ask firms [
    set offshored? false   ;; initially all firms report that they have not offshored
    set reshored? false   ;; no firm has initially reshored
    set relocated? false   ;; no firm has initially relocated
    let offshored-firms ( min-n-of ( count firms * ( share-of-offshored-firms / 100 ) ) firms [ max-level-of-automation ] )   ;; specific share of all firms have decided to produce abroad (see: slider on interface)
      ask offshored-firms [
        setxy random-xcor random-between ( -10 ) -1   ;; spread randomly abroad
        set offshored? true ] ]
  ask firms with [ offshored? = false ] [
    setxy random-xcor random-between ( 10 ) 1 ]   ;; all firms at home are randomly spread across Germany
end


to state-of-the-art   ;; auxiliary code: firms' state of the art of technology
  ask n-of ( count firms * ( share-of-automated-firms / 100 ) ) firms [   ;; particular share of firms which already utilise automated robots
    set level-of-automation random-between ( 0.01 ) max-level-of-automation ]   ;; share of production tasks already automated but less than or equal to their maximum-level-of-automation
  ask firms [
    set color scale-color orange level-of-automation 0 1 ]   ;; firms are black when they are not automated and shade into a ligther orange the more their level of automation increases
end


to technological-progress   ;; auxiliary code: efficiency of automation increases proportional to R&D investment
  ask firms [
    ifelse ( ( level-of-automation + r&d-investment ) < max-level-of-automation ) [   ;; R&D investment cannot increase the level of automation beyond its maximum level
      set level-of-automation level-of-automation + r&d-investment ] [
      set level-of-automation max-level-of-automation  ] ]  ;; maximum of automation has been reached
  ask firms [
    set color scale-color orange level-of-automation 0 1 ]
end


to costs-calculation   ;; auxiliary code: capital is used for production costs and the costs for labour
  ask firms [
    set raw-material-costs capital * ( share-of-raw-material-costs / 100 )   ;; specific share of capital (t0) which is used for raw materials (to be defined in interface)
    set budget-for-labour-costs capital - raw-material-costs ]   ;; specific share of capital (t0) which is used for labour
end


to-report share-of-labour-costs   ;; auxiliary code: reports the share used for labour
  report ceiling ( 100 - share-of-raw-material-costs )
end


to labour-automation-ratio   ;; auxiliary code: labour is proportionally divided between the robots, low- and high-skilled labour defined through their ratio
  ask firms [
    set high-skilled-labour-ratio 1 - low-skilled-labour-ratio   ;; labour ratio adds up to 1 in its sum
    ifelse ( level-of-automation >= robots-kill-jobs-threshold ) [   ;; specific threshold defining the level of automation at which low-skilled labour becomes obsolete
      set actual-low-skilled-labour-ratio 0
      set actual-high-skilled-labour-ratio 1 - level-of-automation ] [
    set actual-low-skilled-labour-ratio ( 1 - level-of-automation ) * low-skilled-labour-ratio   ;; 1 labour unit is the sum of the low-, high-skilled-labour-ratio and the level-of-automation
    set actual-high-skilled-labour-ratio ( 1 - level-of-automation ) * high-skilled-labour-ratio ] ]
end


to employment   ;; auxiliary code: defines the type of labour units employed
  ask firms [
    ;; the ratios determine the varying shares of the three different types of labour units
    let share-of-robots budget-for-labour-costs * level-of-automation
    let share-of-low-skilled-labour budget-for-labour-costs * actual-low-skilled-labour-ratio   ;; defines how many workers can be employed dependening on the disposability of labour costs and the level of wages at home
    let share-of-high-skilled-labour budget-for-labour-costs * actual-high-skilled-labour-ratio
    ;; the disposibility of labour costs and the proportional shares of labour determine the actual number of the varying types of labour units at home by costs and wages
    ;floor: reports the largest integer less than or equal to the number as a decimal number would not be realistic here as the unit of measurment are people
    ifelse ( offshored? = false ) [
      set robots floor ( share-of-robots / robot-costs )
      set low-skilled-labour floor ( share-of-low-skilled-labour / wages-low-skilled-labour-at-home )
      set high-skilled-labour floor ( share-of-high-skilled-labour / wages-high-skilled-labour-at-home )
      set labour-units-at-home robots + low-skilled-labour + high-skilled-labour ] [
      ;; the disposibility of labour costs and the proportional shares of labour determine the actual number of the varying types of labour units abroad by costs and wages
      set robots floor ( share-of-robots / robot-costs )
      set low-skilled-labour floor ( share-of-low-skilled-labour / wages-low-skilled-labour-abroad )
      set high-skilled-labour floor ( share-of-high-skilled-labour / wages-high-skilled-labour-abroad )
      set labour-units-abroad robots + low-skilled-labour + high-skilled-labour ]
    ;; as no decimal number can be used to calculate the number of labour units the planned budget for labour costs and its actual amount differ
    ifelse ( offshored? = false ) [
      set actual-labour-costs (
        robots * robot-costs ) + (
        low-skilled-labour * wages-low-skilled-labour-at-home ) + (
        high-skilled-labour * wages-high-skilled-labour-at-home ) ] [
      set actual-labour-costs (
        robots * robot-costs ) + (
        low-skilled-labour * wages-low-skilled-labour-abroad ) + (
        high-skilled-labour * wages-high-skilled-labour-abroad ) ] ]
end


to output-calculation   ;; auxiliary code: each labour unit achieves to produce a specific amount of output which is defined through their productivity
  ask firms [
      set output ( ( low-skilled-labour + high-skilled-labour ) * labour-productivity ) + (   ;; amount of products produced per manual labour unit employed
      robots * robot-productivity ) ]  ;; amount of products produced per robot utilised
end


to revenue-calculation   ;; auxiliary code: it is assumed that all output is sold to the defined sales price of the product
  ask firms [
    set revenue output * sales-price-per-product ]
end


to r&d-calculation   ;; auxiliary code: share of revenue which is used for R&D investment
  ask firms [
    set r&d-investment revenue * ( share-for-r&d-investment / 100 )
    if level-of-automation = max-level-of-automation [
      set r&d-investment 0 ] ]
end


to profit-calculation   ;; auxiliary code: the profit calculation for the firms which produce at home and abroad differs due to additional costs for foreign surcharges
  ask firms [
    set foreign-surcharges revenue * ( share-for-foreign-surcharges / 100 )
    set profit-at-home revenue - raw-material-costs - actual-labour-costs - r&d-investment
    set profit-abroad revenue - raw-material-costs - actual-labour-costs - r&d-investment - foreign-surcharges ]
end


to location-decision   ;; auxiliary code: if the profit of a firm is smaller even after substracting relocation costs of its profit if it would relocate, than the relocation decision is: yes!
  ask firms with [ offshored? = false ] [
    set relocation-costs ( share-for-relocation-costs / 100 ) * profit-at-home   ;; share of profit which would be needed to relocate production
    if ( profit-at-home < ( profit-abroad - relocation-costs ) ) [
      move-to one-of patches with [ pcolor = 48 and not any? turtles-here ]
      set offshored? true
      set reshored? false
      set relocated? true ] ]
  ask firms with [ offshored? = true ] [
    set relocation-costs ( share-for-relocation-costs / 100 ) * profit-abroad
    if ( profit-abroad < ( profit-at-home - relocation-costs ) ) [
      move-to one-of patches with [ pcolor = 98 and not any? turtles-here ]
      set offshored? false
      set reshored? true
      set relocated? true ] ]
end
...