Car Tax Model

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.1 • Viewed 31 times • Downloaded 0 times • Run 0 times
Download the 'Car Tax Model' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

extensions [ csv ]

globals [ utility ]


breed [ cars car ]
breed [ buyers buyer ]

cars-own
[
  model
  brand
  fuelconsmp
  fuelcost
  co2
  price
  kerbweight
  len
  width
  height
  gasoline
  chosen?       ; boolean variable mobil dipilih oleh pembeli
; chosen-cars
]

buyers-own
[
  hh-size       ; ukuran rumah tangga. Jumlah seluruh orang dalam rumah tangga. (rasio)
  spending      ; pengeluaran bulanan rumah tangga. (ordinal)
  sex           ; jenis kelamin. (nominal)
  age           ; usia pembeli. (ordinal)
  occupation
  cset-size
  choice-set
  car-choice
]

to setup
  clear-all         ; start over the model clean
  file-close-all    ; close any files open from last run

  set-buyers        ; setup the car buyers condition using 'set-buyers' procedure
  set-cars          ; setup the car condition using 'set-cars' procedure

  ;; set patches color
;  ask patches
;  [
;    set pcolor blue
;  ]

  reset-ticks
end 

to set-buyers    ; buyers procedure.
  ifelse not file-exists? buyers_file
  [
    user-message "Tidak ditemukan file 'file_read_buyers.csv'. Mohon periksa kembali nama atau lokasi file tersebut."
    stop
  ]
  [
    file-open buyers_file
  ]

  ;; Membaca seluruh data dalam satu loop
  while [ not file-at-end? ]
  [
    ; here the csv extension grabs a single line and puts the read data in a list
    let baca csv:from-row file-read-line ;
    ; now we can use that list to create a turtle with the saved properties
    create-buyers 1
    [
      set hh-size    item 0 baca
      set spending   item 1 baca
      set occupation item 2 baca
      set sex        item 3 baca
      set age        item 4 baca
    ]

    ask buyers
    [
      set shape        "person"
      set color        green
      let bound-buyers random -45 - 5
      set xcor         bound-buyers
      set ycor         random-ycor
    ]
  ]

  file-close ; make sure to close the file

:;  Baris kode lawas:

;;  create-buyers num-buyers
;;  [
;;    set shape "person"
;;    set color yellow
;;    let bound-buyers random -45 - 5              ;; local variable to choose random number from -5 to -50
;;    set xcor bound-buyers set ycor random-ycor   ;; spread the buyers position by setting the x coordinates from -5 to -50
;;  ]
;;
;;  ;; These following procedures set the distribution of each variable for the buyers
;;  set-household   ; household size
;;  set-pengeluaran      ; pengeluaran level
;;  set-jk         ; jk
;;  set-usia         ; usia
end 

to set-cars  ; cars procedure.

  ifelse not file-exists? cars_file
  [
    user-message "Tidak ditemukan file 'file_read_cars.csv'. Mohon periksa kembali nama atau lokasi file tersebut."
    stop
  ]
  [
    file-open cars_file
  ]

  ;; Membaca seluruh data dalam satu loop
  while [ not file-at-end? ]
  [
    ; here the csv extension grabs a single line and puts the read data in a list
    let baca csv:from-row file-read-line ;
    ; now we can use that list to create a turtle with the saved properties
    create-cars 1
    [
      set model      item 0 baca
      set brand      item 1 baca
      set fuelconsmp item 2 baca
      set fuelcost   item 3 baca
      set co2        item 4 baca
      set price      item 5 baca
      set kerbweight item 6 baca
      set len        item 7 baca
      set width      item 8 baca
      set height     item 9 baca
      set gasoline   item 10 baca
    ]

    ask cars
    [
      set shape        "car"
      set color        yellow
      let bound-cars   random 45 + 5
      set xcor         bound-cars
      set ycor         random-ycor
    ]
  ]

  file-close ; make sure to close the file

;;  create-cars num-cars
;;  [
;;    set shape "car"
;;    set color lime
;;    let bound-cars random 45 + 5
;;    set xcor bound-cars set ycor random-ycor
;;  ]
end 

to choose!
  reset-ticks

  ask cars
  [ set chosen? 0 ]

  first-stage         ; buyers make car choice set that contains a number of cars drawn with non-compensatory rules
                      ; and set them to a list

  second-stage        ; buyers choose one car that maximizes their utlity values from the choice set formed from
                      ; the first step. The

  tick
end 






;to read-cars-data-from-csv
;  file-close-all ; close all open files
;
;  ifelse not file-exists? cars_file
;  [
;    user-message "Tidak ditemukan file 'cars.csv'. Mohon periksa kembali nama atau lokasi file tersebut."
;    stop
;  ]
;  [
;    file-open cars_file
;  ]
;
;  ;; Membaca seluruh data dalam satu loop
;  while [ not file-at-end? ]
;  [
;    ; here the csv extension grabs a single line and puts the read data in a list
;    let baca csv:from-row file-read-line
;    ; now we can use that list to create a turtle with the saved properties
;    create-cars 1
;    [
;      set brand    item 0 baca
;      set model    item 1 baca
;      set fuelconsmp    item 2 baca
;    ]
;  ]
;
;  file-close ; make sure to close the file
;end

to first-stage  ; buyers procedure.
  ask buyers
  [
    let a 4
    let b 1 / 6
    set cset-size round random-gamma a b ;; set the number of cars choice set for each buyer by the non-compensatory rule
    set choice-set [who] of (n-of cset-size cars)      ;; set buyers' car choice-set as an usiantset
    set label cset-size
  ]
end 

to second-stage  ; buyers procedure.
  ;; KOSONG MULU NIH, AYO DONG CEPETAN ISI
  ;; SABAR, ORANG LAGI PUSING JUGA

  ask buyers
  [
    let chosen-car one-of choice-set
    ask car chosen-car
    [
      set chosen? 1
    ]
    set label chosen-car
    set car-choice chosen-car
  ]
end 


;to set-household   ; buyers procedure.
;  let %1 0.8
;  let %2 0.1
;  let portion1 round (count buyers * %1)
;  let portion2 round (count buyers * %2)
;
;  ask n-of (portion1) buyers [ set uku-rt 5 ]
;  ask n-of (portion2) buyers [ set uku-rt 3 ]
;  ask n-of (count buyers - (portion1 + portion2)) buyers [ set uku-rt 2 ]
;end
;
;
;to set-pengeluaran
;  let %1 0.8
;  let %2 0.1
;  let portion1 round (count buyers * %1)
;  let portion2 round (count buyers * %2)
;
;  ask n-of (portion1) buyers [ set pengeluaran 5 ]
;  ask n-of (portion2) buyers [ set pengeluaran 3 ]
;  ask n-of (count buyers - (portion1 + portion2)) buyers [ set pengeluaran 2 ]
;end
;
;
;to set-jk
;  ;; jk 0 is for male, jk 1 is for female
;  let %1 0.5
;  let portion1 round (count buyers * %1)
;
;  ask n-of (portion1) buyers [ set jk 0 ]
;  ask n-of ((count buyers) - portion1) buyers [ set jk 1 ]
;end
;
;
;to set-usia
;  let %1 0.5
;  let portion1 round (count buyers * %1)
;
;  ask n-of (portion1) buyers [ set usia 1 ]
;  ask n-of (count buyers - portion1) buyers [ set usia 2 ]
;end


;; These line of codes place arguments to set values of the buyers' characteristics.
;; The 'n-of' is still set to be stationary according to the number of buyers rather than
;; dynamic value regarded the percentusia/proportion. This is because of the uncertain output
;; of the dynamic one which has not been figured out yet why.

to-report buyers-utility
end 

There are 2 versions of this model.

Uploaded by When Description Download
Muhammad Abdul Mubdi Bindar 3 months ago hopefully solves the extensions issue Download this version
Muhammad Abdul Mubdi Bindar 3 months ago Initial upload Download this version

Attached files

File Type Description Last updated
file_read_buyers.csv extension 'buyers' breed file 3 months ago, by Muhammad Abdul Mubdi Bindar Download
file_read_cars.csv extension 'cars' breed file 3 months ago, by Muhammad Abdul Mubdi Bindar Download

This model does not have any ancestors.

This model does not have any descendants.