Yu_Thomas_GasPrice
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This is a basic model of interaction between personal vehicles and gas stations, and the effects of such interaction on the gas prices of the gas stations. The model takes into account of the layout of the world, which includes realistic features such as roads and city blocks, and attempts to simulate the various factors that affects the gas price.
HOW IT WORKS
The world is setup to simulate a typical grid design for urban design, with roads running between individual city blocks. Three categories of patches are spawned within the city blocks, which are homes, gas stations, and destinations. The density of all three patches
Each home patch sprouts one turtle, which is then assigned as vehicle. The location of home patch is stored within each of the corresponding vehicle. Once the _Go_ button is pressed by the users, the vehicle would randomly determine a destination from the all of the destination patches within the world. It would then proceed to travel to the destination by following the roads. Upon reaching its destination, the vehicle would first return to its home patch and then proceed to travel to another destination.
Every step made by the vehicle consumes some gas from the initial amount of gas given to each vehicle, which is randomly determined. If the gas level of the vehicle falls below a certain critical value, the vehicle would try to find a gas station to fill through one of the two modes of searching.
In the first mode, the vehicle would simply find the closest gas station relative to its current location. As for the second mode, the vehicle first determines how many gas stations are with a certain radius of its current location. If there is only one gas station within the radius, the vehicle would then travel to this station and proceed to fill up its gas tank. If there are multiple stations, the vehicle would then travel to the one with the cheapest gas price.
For the gas station, its gas price is depended on the time it takes for the station to sell most of its gas. If the gas is sold out in a really short time, the gas price would rise. However, if there isn_t any visit to the gas station for a certain amount of time, the price of the gas at the station would be reset to a value slightly lower than the mean price of all stations. A switch function is also added to the program. It allows the gas price to randomly fluctuate.
HOW TO USE IT
1. Set RANDOM_FLUCTUATION? Switch to ON to allow the price to varies randomly by a small amount, or to OFF to only allow the price to change by the behavior of the vehicles
2. Adjust the variable parameters (see below), or use the default settings.
3. Press the SETUP button.
4. Press the GO button to begin the simulation
5. Look at the monitor to see movement of the vehicles and changes to the gas station_s reservoirs
6. Look at the Average Gas Price plot to see the change in the mean price of gas
Adjustable Slider:
_DEST-PROB_ _ control the density of destination patches within the world
_HOME-PROB_ _ control the density of home patches within the world
_GAS-PROB_ _ control the density of gas station patches within the world
_RANGE_OF_GASSTATIONS_CONSIDER_ _ control the radius for the vehicle to compare the availability and price of the gas.
Chooser Box:
_GAS-SEARCHING-MODE_ _ Determine which mode that the vehicles use to search for a gas station. See "HOW IT WORKS" section for detailed explanation of the two modes.
Switch:
_RANDOM_FLUCTUATION?_ _ Determine whether or not introduction a random fluctuation in the gas price of each station
THINGS TO NOTICE
- Switch the chooser, "DISPLAY_PARAMETER", between displaying the gasoline price and reservior level. Notice any correlation between the gas price and the drainage speed.
- Turn the random fluctuation function on. Notice any changes to the behavior of the vehicles.
THINGS TO TRY
- Try changing to "GAS-SEARCHING-MODE", see what effects it has on the movement of the vehciles
- Try lowering the number of gas stations within the world. Does that affect the rate of change for the gasoline price? How about having more or less home patches and vehicles in the world?
- Some stations provides higher quality fuel, which attracts more vehicles, but the gasoline price is slightly higher.
EXTENDING THE MODEL
- In the real world, residential regions or commerical districts tend form close to each other. Add a switchable function that allow the home patches and/or destination patches to be located close to each other.
- The driving behavior of the vehicles are heavily influenced by the traffic condition of the roads that are being used. Improve the current "MOVE" command, so that the speed of the vehicles are affected by how many other vehicles are using the same stretch of road. Features like traffic lights can also be added to the existing intersection.
- Currently all roads are treated the same by the vehicles. Such is not true in the real world, as vehicles are more likely to take highway or expressway to increase the speed of travel and fuel efficiency. Introduce such feature to the Netlogo model.
RELATED MODELS
"Traffic Grid" model within the Social Science section of the Netlogo build-in library is related to this model, as the same city layour was used.
CREDITS AND REFERENCES
The codes for the setup of the city blocks was constructed with the ones from the "Traffic Grid" model.
Comments and Questions
globals [ grid-x-b ;; determine the size of the city blocks grid-y-b roads intersections ;; determine where the intersections are homes destinations gasstations gasstations_ex ;; for making an interactive patch right next to the actual gas station patch gas-time ;; for counting the time it takes for the gas station to sell out most of its fuel reserve ] turtles-own [ car energy ;; for counting how much gas is left in the vehicle homexy ;; for storing the location of the home patch with the vehicle dest ;; for storing the location of the desintation fdest ;; for storing the locaiton of the gas station ] patches-own [ count-neighbors ;; for counting the number of corresponding patches around one patch count-homes count-gaspatch count-intersections gas-level ;; for determining the amount of gas left and the current gas price at the gas station patch gas-price ] to setup clear-all setup-globals setup-patches setup-homes setup-gasstation setup-dest set-default-shape turtles "car" ask patches [ if pcolor = green [ sprout 1 ;; sprout a car on each home patch ] ] ask gasstations_ex [ set gas-level 2000 ;; give 2000 gas "points" to each station at the start set gas-price random-normal 3.5 0.5 ;; price of gasoline is determine from a random distribution with mean of 1 and standard deviation of 1 ] ask turtles [ set energy random 300 ;; each vehicle has a random amount of gas at start, with max. value of 300 set car turtles set homexy min-one-of (patches with [pcolor = green]) [distance myself] ;; location of the closest home patch is stored as the home patch for the vehicle set dest one-of destinations ;; pick one random destination patch as the desintation move-to min-one-of (patches with [pcolor = pink]) [distance myself] ;; move the turtles to the closest intersection patch, so they can determine where to turn ] if display_parameter = "Level" [ ask gasstations_ex [ set plabel gas-level ;; create the extension patch for gas station, initialize its refuelling timer and setup label for the level of gas left in the station set plabel-color black set gas-time 1 ] ] if display_parameter = "Price" [ ask gasstations_ex [ set plabel gas-price ;; create the extension patch for gas station, initialize its refuelling timer and setup label for the current price at the station set plabel-color black set gas-time 1 ] ] setup-plot update-plot end to setup-plot set-current-plot "Average Gas Price" ;; initialize the plot for average gas price end to update-plot set-current-plot-pen "Mean Price" ;; update the plot with the current mean gas price plot mean [gas-price] of gasstations_ex end to setup-globals set grid-x-b world-width / grid-size ;; determine the size of the city blocks set grid-y-b world-width / grid-size end to setup-patches ask patches [ ;; change the city block's color into brown set pcolor brown] set roads patches with [ ( floor (( pxcor + max-pxcor - floor (grid-x-b - 1)) mod grid-x-b) = 0 ) or ;; setup the road patches between the city block (floor((pycor + max-pycor) mod grid-y-b) = 0 ) ] ask roads [ set pcolor white ] ask roads [ set count-intersections count neighbors4 with [pcolor = white] ;; determine the locations of the intersections if count-intersections = 4 [ set pcolor pink ] ;; change their color to pink for easier identification ] end to setup-homes ask patches [ set count-neighbors count neighbors4 with [pcolor = white] ] ask patches [ if pcolor = brown and count-neighbors > 0 [ ;; if the patch is at the edges of the city block, if random-float 10 > (10 - home-prob) [ ;; it will randomly turn into a home patch, based on the set probability set pcolor green ] ] ] set homes patches with [ pcolor = green ] end to setup-gasstation ask patches [ set count-neighbors count neighbors4 with [pcolor = white] ] ask patches [ if pcolor = brown and count-neighbors = 1 [ ;; if the patch is at the edges of the city block, if random-float 10 > (10 - gas-prob) [ ;; it will randomly turn into a gas station patch, based on the set probability set pcolor grey ] ] ] set gasstations patches with [ pcolor = grey ] ask patches [ set count-gaspatch count neighbors4 with [pcolor = grey] ;; turn the road patch right next to the gas station patch if pcolor = white and count-gaspatch = 1 [ ;; into an extension patch set pcolor red ] set gasstations_ex patches with [ pcolor = red ] ] ask gasstations_ex [ set pcolor white ] end to setup-dest ask patches [ set count-neighbors count neighbors4 with [pcolor = white] ;; setup destination patches, with the same methodology set count-homes count neighbors with [pcolor = green ] ;; as the home and gas station patches ] ask patches [ if pcolor = brown and pcolor != grey and pcolor != green and count-neighbors > 0 and count-homes = 0 [ if random-float 10 > (10 - dest-prob) [ set pcolor orange ] ] ] set destinations patches with [ pcolor = orange ] end to go ask turtles [ ifelse energy < 40 [ ifelse gas-searching-mode = "Mode 1" ;; if the vehicle has reached critical fuel level, it will [ move-to-gas-mode1 ] [ ;; look for gas stations to fuel up, based on one of the selected if gas-searching-mode = "Mode 2" ;; modes [ move-to-gas-mode2 ] ] ] [ ifelse distance dest < 2 ;; determine whether the car has reached its destination [ ifelse distance homexy < 2 and distance homexy = distance dest ;; if the destination is a home patch, [ set dest one-of destinations ] ;; the vehicle will selected a new desintation. [ set dest homexy ] ;; if not, it will return to its home patch ] [ move ] ;; the vehicle will move toward the gas station ] ] ask gasstations_ex[ ;; setup interaction between the gas stations and the vehicle, if there is any check-gas-level update-label ] update-plot tick end to move if [pcolor] of patch-here = pink [ ;; if the vehicle is at the intersection, face dest ;; face directly to the selected destination, if heading <= 45 [ ;; and compare the direction to one of the four possible routes at the intersection. set heading 0 ] ;; Select the route that gives the least deviation to the direct heading. if heading > 315 [ set heading 0] if heading > 45 and heading <= 135 [ set heading 90 ] if heading > 135 and heading <= 225 [ set heading 180 ] if heading > 225 and heading <= 315 [ set heading 270 ] ] fd 1 set energy energy - 1 ;; consume one gas "point" for every step end to move-to-gas-mode1 set fdest min-one-of gasstations_ex [distance myself] ;; select the closest gas station if [pcolor] of patch-here = pink [ ;; travel toward the selected gas station using the same logic as above face fdest if heading <= 45 [ set heading 0 ] if heading > 315 [ set heading 0] if heading > 45 and heading <= 135 [ set heading 90 ] if heading > 135 and heading <= 225 [ set heading 180 ] if heading > 225 and heading <= 315 [ set heading 270 ] ] fd 1 set energy energy - 1 if distance fdest < 1 ;; if the vehicle is right on top of the gas station, [ set gas-level (gas-level - (300 - energy)) ;; it will proceed to fuel up by resetting its gas level to full tank, set energy 300 ;; and deduct the corresponding amount from the gas station's reservior ] end to move-to-gas-mode2 if energy < 40 [ let cheapest-gas count gasstations_ex in-radius (range_of_gasstations_consider) ;; counts the number of gas station with a radius ifelse cheapest-gas < 2 [ set fdest min-one-of gasstations_ex [distance myself] ] ;; if there is less than two gas stations within the radius, the vehicle will just travel to the closest one [ set fdest min-one-of (gasstations_ex in-radius range_of_gasstations_consider) [gas-price] ] ;; if there are multiple gas stations around, it will selected the cheapest station within the radius ] if [pcolor] of patch-here = pink [ face fdest if heading <= 45 [ set heading 0 ] if heading > 315 [ set heading 0] if heading > 45 and heading <= 135 [ set heading 90 ] if heading > 135 and heading <= 225 [ set heading 180 ] if heading > 225 and heading <= 315 [ set heading 270 ] ] fd 1 set energy energy - 1 if distance fdest < 1 [ set gas-level (gas-level - (300 - energy)) set energy 300 ] end to check-gas-level set gas-time gas-time + 1 ;; count the time between replenishment of the gas stations if gas-time > 500 and gas-level > 1500 [ ;; if the gas station have not had any visitor for the last 500 ticks, and the gas level is above 1500 set gas-price ( mean [gas-price] of gasstations_ex - (random-float 0.5) ) ;; it will reset its price to slightly below the average gas price set gas-time 0 ;; and reset the counter ] if gas-level < 300 [ ;; if the gas station is selling out most of its fuel, set gas-level 2000 ;; its fuel tank is replenished set gas-price ( gas-price - (gas-time - 400) / 1000 ) ;; a new price is determined by how fast did it take to sell out most of reserve set gas-time 0] ;; reset time counter if random_fluctuation? [ ;; introduce a switch for random fluctuations let prob_change random 10 if prob_change < 2 [ set gas-price ( gas-price - random-float 0.5 + random-float 0.5 ) ] ] end to update-label ;; update the label showing the current amount of gas in the reservior or the current price of the station ask gasstations_ex [ if display_parameter = "Level" [ set plabel gas-level ] if display_parameter = "Price" [ set plabel gas-price ] ] end
There are 2 versions of this model.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.