-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
541 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
152 changes: 152 additions & 0 deletions
152
Code/06 Modelling Introduction/Advertising Impact Stella Model.stmx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xmile version="1.0" xmlns="http://docs.oasis-open.org/xmile/ns/XMILE/v1.0" xmlns:isee="http://iseesystems.com/XMILE"> | ||
<header> | ||
<smile version="1.0" namespace="std, isee"/> | ||
<name>Advertising Impact Stella Model</name> | ||
<uuid>bf4a89c5-ab71-49f2-b522-f5dedfc36701</uuid> | ||
<vendor>isee systems, inc.</vendor> | ||
<product version="3.7.1" isee:build_number="3377" isee:saved_by_v1="true" lang="en">Stella Architect</product> | ||
</header> | ||
<sim_specs isee:sim_duration="1.5" isee:run_prefix="Run" isee:simulation_delay="0.06" isee:restore_on_start="false" method="Euler" time_units="Months" isee:instantaneous_flows="false" isee:ignore_module_errors="false" isee:strict_units="true" isee:loop_scores="true" isee:loop_exhaustive_allowed="1000"> | ||
<start>0</start> | ||
<stop>25</stop> | ||
<dt reciprocal="true">4</dt> | ||
</sim_specs> | ||
<isee:prefs saved_runs="5" keep="false" show_module_prefix="true" live_update_on_drag="true" show_restore_buttons="false" layer="model" isee:design="Deluxe Prev-Next Blue Green Pastel" isee:design_custom="false" interface_scale_ui="true" interface_max_page_width="10000" interface_max_page_height="10000" interface_min_page_width="0" interface_min_page_height="0" rerun_on_structure_change="false" rifp="true"/> | ||
<isee:multiplayer_settings include_chat="true" allow_observers="false" advance_time_increment="1" max_advance_time_in_ms="0" model_stops_when_players_drop="false" observer_start_page="home_page" enabled="false"/> | ||
<isee:time_formats default_format="Builtin"> | ||
<isee:time_format name="Builtin" type="adaptive"/> | ||
</isee:time_formats> | ||
<isee:number_format_extenders/> | ||
<default_format/> | ||
<model_units/> | ||
<model> | ||
<variables> | ||
<stock name="Advertising Impact"> | ||
<eqn>100</eqn> | ||
<outflow>Loss_of_Impact</outflow> | ||
</stock> | ||
<flow name="Loss of Impact"> | ||
<eqn>Advertising_Impact*Loss_Fraction</eqn> | ||
<non_negative/> | ||
</flow> | ||
<aux name="Loss Fraction"> | ||
<eqn>.1</eqn> | ||
</aux> | ||
</variables> | ||
<views> | ||
<style color="black" background="white" font_style="normal" font_weight="normal" text_decoration="none" text_align="center" vertical_text_align="center" font_color="black" font_family="Arial" font_size="10pt" padding="2" border_color="black" border_width="thin" border_style="none"> | ||
<text_box color="black" background="white" text_align="left" vertical_text_align="top" font_size="12pt"/> | ||
<isee:loop_indicator color="black" background="white" vertical_text_align="top" font_size="12pt"/> | ||
<numeric_display color="white" background="white" font_size="12pt" border_width="thin" border_style="solid" isee:transparent="false" isee:show_divider="true" isee:show_bounding_box="true" label_side="left"/> | ||
<graph color="black" background="white" font_size="12pt" axis_color="#666666" grid_color="#C8C8C8" isee:graph_area_color="white" legend_position="bottom" isee:transparent="false" isee:hide_border="false" axis_title_font_style="normal" axis_title_font_weight="normal" axis_title_text_decoration="none" axis_title_text_align="center" axis_title_vertical_text_align="center" axis_title_font_color="black" axis_title_font_family="Arial" axis_title_font_size="12pt" axis_title_text_padding="2" axis_title_text_border_color="black" axis_title_text_border_width="thin" axis_title_text_border_style="none" axis_label_font_style="normal" axis_label_font_weight="normal" axis_label_text_decoration="none" axis_label_text_align="center" axis_label_vertical_text_align="center" axis_label_font_color="black" axis_label_font_family="Arial" axis_label_font_size="9pt" axis_label_text_padding="2" axis_label_text_border_color="black" axis_label_text_border_width="thin" axis_label_text_border_style="none"> | ||
<isee:series_styles> | ||
<isee:series_style color="blue" thickness="1"/> | ||
<isee:series_style color="red" thickness="1" pen_style="dot_dashed"/> | ||
<isee:series_style color="fuchsia" thickness="1" pen_style="dotted"/> | ||
<isee:series_style color="#008F44" thickness="1" pen_style="dashed"/> | ||
<isee:series_style color="#FF7F00" thickness="1"/> | ||
<isee:series_style color="#7F00FF" thickness="1" pen_style="dot_dashed"/> | ||
<isee:series_style color="#0CA0FF" thickness="1" pen_style="dotted"/> | ||
<isee:series_style color="lime" thickness="1" pen_style="dashed"/> | ||
<isee:series_style color="#FF007F" thickness="1"/> | ||
<isee:series_style color="aqua" thickness="1" pen_style="dot_dashed"/> | ||
<isee:series_style color="#F586FF" thickness="1" pen_style="dotted"/> | ||
<isee:series_style color="black" thickness="1" pen_style="dashed"/> | ||
<isee:series_style color="#C8C8C8" thickness="1"/> | ||
</isee:series_styles> | ||
</graph> | ||
<table color="black" background="#E0E0E0" text_align="right" font_size="12pt" orientation="vertical" wrap_text="false" isee:auto_fit="true" isee:use_alternate_row_colors="false" isee:unlimited_table_length="false" blank_column_width="80" column_width="160" interval="1" report_balances="beginning" report_flows="instantaneous" header_font_style="normal" header_font_weight="normal" header_text_decoration="none" header_text_align="center" header_vertical_text_align="center" header_font_color="black" header_font_family="Arial" header_font_size="12pt" header_text_padding="2" header_text_border_color="black" header_text_border_width="thin" header_text_border_style="none"/> | ||
<button color="black" background="#E0E0E0" font_size="12pt" border_width="thin" border_style="solid" transparent="false" corner_radius="0" isee:flat="false" icon_side="top" isee:highlight_on_hover="false" isee:highlight_color="#959595"/> | ||
<isee:annotation color="black" background="#E0E0E0" font_size="12pt" border_width="thin" border_style="solid" transparent="false" corner_radius="0" isee:flat="false" icon_side="top" isee:highlight_on_hover="false" isee:highlight_color="#959595" popup_corner_radius="0" popup_background_color="#FFFECF"/> | ||
<slider color="#66CC66" background="#E0E0E0" font_size="12pt" num_ticks="3" label_side="top" wrap_title="true" vertical="false" isee:fancy_appearance="false" isee:show_hover_tip="when_deciding" input_expands="true" input_width="100"/> | ||
<isee:stacked_container color="black" background="white" text_align="left" vertical_text_align="top" font_size="12pt" padding="6 8" border_color="#999999" border_width="thin" border_style="solid" item_spacing="0" corner_radius="4" selected_item_color="black" selected_item_background="white" item_background="#DDDDDD" transparent_bg="false"/> | ||
<isee:dual_slider color="#66CC66" background="silver" font_size="12pt" num_ticks="3" label_side="top" wrap_title="true" isee:show_hover_tip="when_deciding" input_expands="true" input_width="100"/> | ||
<isee:sim_speed_slider color="black" background="white"/> | ||
<isee:time_slider color="#E95F74" background="silver"/> | ||
<isee:pie_input color="black" background="white" font_size="12pt" legend_position="bottom" isee:transparent="false"/> | ||
<knob color="#66CC66" background="#E0E0E0" font_size="12pt" label_side="bottom" wrap_title="true"/> | ||
<numeric_input color="black" background="#E0E0E0" font_size="12pt" label_side="left" wrap_title="true" input_expands="false" input_width="100"/> | ||
<isee:dropdown_input color="black" background="#E0E0E0" font_size="12pt" label_side="left" wrap_title="true" input_expands="false" input_width="100"/> | ||
<switch color="black" background="#E0E0E0" font_size="12pt" label_side="top" wrap_title="true" isee:appearance="switch" isee:on_color="green"/> | ||
<options color="black" background="white" appearance="radio-buttons" arrangement="vertical"/> | ||
<graphical_input color="black" background="#E0E0E0" font_size="12pt" isee:show_hover_tip="true"/> | ||
<group_input color="black" background="#E0E0E0" font_size="12pt"/> | ||
<lamp color="black" background="white" font_size="9pt"/> | ||
<gauge color="black" background="white" font_size="9pt" needle_color="#F09F72" bar_color="#EEEEEE" bar_progress_color="black" appearance="radial" num_major_ticks="11" num_minor_ticks="1" show_numeric_value="true"/> | ||
<isee:spatial_map color="black" background="white" font_size="12pt"/> | ||
<isee:animation_object color="black" background="white" font_size="12pt"/> | ||
<isee:navigation_widget color="black" background="white" text_align="left" vertical_text_align="top" font_size="12pt" padding="6 8" border_color="#999999" border_width="thin" border_style="solid" item_spacing="6" appearance="tabs" corner_radius="4" selected_item_color="black" selected_item_background="white" item_background="#DDDDDD" transparent_bg="false"/> | ||
<isee:shape color="black" background="white" text_align="left" vertical_text_align="top" font_size="12pt" border_width="thin" border_style="solid" opacity="1" transparent_background="true" corner_radius="1"/> | ||
<isee:selector color="black" background="white" text_align="left" vertical_text_align="top" font_size="12pt"/> | ||
<isee:iframe color="black" background="white" text_align="left" vertical_text_align="top" font_size="12pt" border_width="thin" border_style="solid"/> | ||
<isee:financial_table color="black" background="#E0E0E0" text_align="right" font_size="12pt" hide_border="false" auto_fit="true" first_column_width="250" other_column_width="100" header_font_style="normal" header_font_weight="bold" header_text_decoration="none" header_text_align="center" header_vertical_text_align="center" header_font_color="black" header_font_family="Arial" header_font_size="14pt" header_text_padding="2" header_text_border_color="black" header_text_border_width="thin" header_text_border_style="none"/> | ||
</style> | ||
<view isee:show_pages="false" background="white" page_width="822" page_height="575" isee:page_cols="2" isee:popup_graphs_are_comparative="true" isee:enable_non_negative_highlights="false" type="stock_flow"> | ||
<style color="black" background="white" font_style="normal" font_weight="normal" text_decoration="none" text_align="center" vertical_text_align="center" font_color="black" font_family="Arial" font_size="10pt" padding="2" border_color="black" border_width="thin" border_style="none"> | ||
<stock color="blue" background="white" font_color="blue" font_size="9pt" label_side="top"> | ||
<shape type="rectangle" width="45" height="35"/> | ||
</stock> | ||
<flow color="blue" background="white" font_color="blue" font_size="9pt" label_side="bottom"> | ||
<shape type="circle" radius="18"/> | ||
</flow> | ||
<isee:placeholder color="#228B22" background="white" font_color="#228B22" font_size="9pt" label_side="bottom"/> | ||
<module color="blue" background="white" font_color="blue" font_size="9pt" label_side="top"> | ||
<shape type="rectangle" width="55" height="45"/> | ||
</module> | ||
<aux color="blue" background="white" font_color="blue" font_size="9pt" label_side="bottom"> | ||
<shape type="circle" radius="18"/> | ||
</aux> | ||
<group color="red" background="white" font_color="red" font_size="9pt"/> | ||
<connector color="#FF007F" background="white" font_color="#FF007F" font_size="9pt" isee:thickness="1"/> | ||
<text_box color="black" background="white" text_align="left" vertical_text_align="top" font_size="12pt"/> | ||
<isee:loop_indicator color="black" background="white" vertical_text_align="top" font_size="12pt"/> | ||
<numeric_display color="white" background="white" font_size="12pt" border_width="thin" border_style="solid" isee:transparent="false" isee:show_divider="true" isee:show_bounding_box="true" label_side="left"/> | ||
<graph color="black" background="white" font_size="12pt" axis_color="#666666" grid_color="#C8C8C8" isee:graph_area_color="white" legend_position="bottom" isee:transparent="false" isee:hide_border="false" axis_title_font_style="normal" axis_title_font_weight="normal" axis_title_text_decoration="none" axis_title_text_align="center" axis_title_vertical_text_align="center" axis_title_font_color="black" axis_title_font_family="Arial" axis_title_font_size="12pt" axis_title_text_padding="2" axis_title_text_border_color="black" axis_title_text_border_width="thin" axis_title_text_border_style="none" axis_label_font_style="normal" axis_label_font_weight="normal" axis_label_text_decoration="none" axis_label_text_align="center" axis_label_vertical_text_align="center" axis_label_font_color="black" axis_label_font_family="Arial" axis_label_font_size="9pt" axis_label_text_padding="2" axis_label_text_border_color="black" axis_label_text_border_width="thin" axis_label_text_border_style="none"> | ||
<isee:series_styles> | ||
<isee:series_style color="blue" thickness="1"/> | ||
<isee:series_style color="red" thickness="1" pen_style="dot_dashed"/> | ||
<isee:series_style color="fuchsia" thickness="1" pen_style="dotted"/> | ||
<isee:series_style color="#008F44" thickness="1" pen_style="dashed"/> | ||
<isee:series_style color="#FF7F00" thickness="1"/> | ||
<isee:series_style color="#7F00FF" thickness="1" pen_style="dot_dashed"/> | ||
<isee:series_style color="#0CA0FF" thickness="1" pen_style="dotted"/> | ||
<isee:series_style color="lime" thickness="1" pen_style="dashed"/> | ||
<isee:series_style color="#FF007F" thickness="1"/> | ||
<isee:series_style color="aqua" thickness="1" pen_style="dot_dashed"/> | ||
<isee:series_style color="#F586FF" thickness="1" pen_style="dotted"/> | ||
<isee:series_style color="black" thickness="1" pen_style="dashed"/> | ||
<isee:series_style color="#C8C8C8" thickness="1"/> | ||
</isee:series_styles> | ||
</graph> | ||
<table color="black" background="#E0E0E0" text_align="right" font_size="12pt" orientation="vertical" wrap_text="false" isee:auto_fit="true" isee:use_alternate_row_colors="false" isee:unlimited_table_length="false" blank_column_width="80" column_width="160" interval="1" report_balances="beginning" report_flows="instantaneous" header_font_style="normal" header_font_weight="normal" header_text_decoration="none" header_text_align="center" header_vertical_text_align="center" header_font_color="black" header_font_family="Arial" header_font_size="12pt" header_text_padding="2" header_text_border_color="black" header_text_border_width="thin" header_text_border_style="none"/> | ||
</style> | ||
<stock x="395" y="328" name="Advertising Impact"/> | ||
<flow x="511.75" y="328" name="Loss of Impact"> | ||
<pts> | ||
<pt x="417.5" y="328"/> | ||
<pt x="630" y="328"/> | ||
</pts> | ||
</flow> | ||
<aux x="569" y="239" name="Loss Fraction"/> | ||
<connector uid="1" angle="282.724"> | ||
<from>Loss_Fraction</from> | ||
<to>Loss_of_Impact</to> | ||
</connector> | ||
<connector uid="2" angle="320.711"> | ||
<from>Advertising_Impact</from> | ||
<to>Loss_of_Impact</to> | ||
</connector> | ||
<stacked_container uid="3" x="923" y="388"> | ||
<table interval="DT" report_balances="beginning" report_flows="instantaneous" width="350" height="250"> | ||
<item type="time"/> | ||
<item> | ||
<entity name="Advertising_Impact"/> | ||
</item> | ||
</table> | ||
</stacked_container> | ||
</view> | ||
</views> | ||
</model> | ||
</xmile> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import numpy as np | ||
import pandas as pd | ||
|
||
|
||
# define the function. For teh numerical solution, the function runs the | ||
# entire simulation | ||
|
||
def sim_advertising_impact_euler(init, time, DT, loss_fraction): | ||
sim_out = np.zeros(len(time)) | ||
sim_out[0] = init | ||
print(sim_out) | ||
for i in range(1,len(time)): | ||
net_flow = -sim_out[i-1]*loss_fraction | ||
sim_out[i] = sim_out[i-1] + net_flow*DT | ||
print("index",i,"time",time[i],"sim_out",sim_out[i]) | ||
|
||
return sim_out | ||
|
||
|
||
|
||
DT = 0.25 | ||
time = np.arange(0,25,DT) | ||
print(time) | ||
sim_advertising_impact_euler(100,time,DT,0.1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import numpy as np | ||
import pandas as pd | ||
|
||
# This function needs: the initial value, the current time, and the decay rate, | ||
def sim_advertising_impact(init_value, time,loss_fraction): | ||
return init_value*np.exp(-loss_fraction*time) | ||
|
||
# Create a time vector. The number of elements for this model is arbitrary. | ||
time=np.arange(25) | ||
|
||
# Create the simulation output array | ||
sim=np.zeros(25) | ||
# print("Time",time) | ||
# print("Sim",sim) | ||
|
||
# Set the initial condition for advertising impact = 100 (Percent) | ||
init = 100 | ||
|
||
# Set the decay rate of 10% per time unit | ||
lf = .1 | ||
|
||
# Run the model. | ||
for i,t in enumerate(time): | ||
sim[i] = sim_advertising_impact(init,t,lf) | ||
|
||
# print("Sim",sim) | ||
|
||
# Plot the results | ||
s = pd.Series(sim, index=time); | ||
s.plot(style="ko--",title="Advertising Impact",grid=True); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.