Skip to content

Commit 7296f35

Browse files
authored
typo in new measurements example (#1151)
* typo in new measurements example * also concrete agent type * shown * remove uncessary agent type * correct header * clarify changing rule
1 parent 12746cf commit 7296f35

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Agents"
22
uuid = "46ada45e-f475-11e8-01d0-f70cc89e6671"
33
authors = ["George Datseris", "Tim DuBois", "Aayush Sabharwal", "Ali Vahdati", "Adriano Meligrana"]
4-
version = "6.2.8"
4+
version = "6.2.9"
55

66
[deps]
77
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"

examples/measurements.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ function update_surface_temperature!(pos, model)
106106
absorbed_luminosity = (1 - daisy.albedo) * model.solar_luminosity
107107
end
108108
## Here we changed the rule to not use `log` because it isn't defined for negative numbers!
109+
## We also need to somehow extract a number from the uncertain number, because boolean
110+
## comparisons are not defined on uncertain numbers.
109111
local_heating = meanval(absorbed_luminosity) > 0 ? 72 *(2absorbed_luminosity - 1.8) + 80 : 80
110112
model.temperature[pos...] = (model.temperature[pos...] + local_heating) / 2
111113
end
@@ -145,20 +147,21 @@ function daisyworld(;
145147
ratio = 0.5, temperature = fill(starting_temperature, griddims)
146148
)
147149

148-
model = StandardABM(Daisy, space; properties, rng, agent_step! = daisy_step!, model_step! = daisyworld_step!)
150+
T = typeof(albedo_black)
151+
model = StandardABM(Daisy{T}, space; properties, rng, agent_step! = daisy_step!, model_step! = daisyworld_step!)
149152

150153
## populate the model with random white daisies
151154
grid = collect(positions(model))
152155
L = length(grid)
153156
white_positions = sample(rng, grid, round(Int, init_white*L); replace = false)
154157
for wp in white_positions
155-
add_agent!(wp, Daisy, model, :white, rand(abmrng(model), 0:max_age), albedo_white)
158+
add_agent!(wp, model, :white, rand(abmrng(model), 0:max_age), albedo_white)
156159
end
157160
## and black daisies
158161
possible_black = setdiff(grid, white_positions)
159162
black_positions = sample(rng, possible_black, Int(init_black*L); replace = false)
160163
for bp in black_positions
161-
add_agent!(bp, Daisy, model, :black, rand(abmrng(model), 0:max_age), albedo_black)
164+
add_agent!(bp, model, :black, rand(abmrng(model), 0:max_age), albedo_black)
162165
end
163166

164167
for p in positions(model)
@@ -213,11 +216,11 @@ end
213216

214217
run_plot_daisyworld()
215218

216-
# Right, this looks great! As expected, there is no band plot showed in the temperature
219+
# Right, this looks great! As expected, there is no band plot shown in the temperature
217220
# axis as there is no uncertainty yet. Let's change that!
218221

219-
# %%
220-
# ## Running Daisyworld without uncertainty
222+
# %% #src
223+
# ## Running Daisyworld with uncertainty
221224

222225
# All we have to do to enable uncertainty is change the daisy albedos and starting
223226
# temperature into numbers with uncertainty. This is as simple as changing three keywords:

0 commit comments

Comments
 (0)