diff --git a/examples/example_1 copy.jl b/examples/example_1 copy.jl new file mode 100644 index 0000000..35320ae --- /dev/null +++ b/examples/example_1 copy.jl @@ -0,0 +1,82 @@ +using NAssets +using Plots +using GraphRecipes + + +ntw_size = 9 +ntw_topo = 4 +n_steps = 100 +# Prepare base simulation configuration +bcfg = ( + seed = 123, + ntw_topo = ntw_topo, + size = ntw_size, + ctl_model = 7, + ctl_k = 3, + ctl_B = 0.7, + # prob_random_walks = 0.8, + n_steps = n_steps, + deterioration = [ (rul,t,a) -> rul - a 1 ], + traffic_dist_params = [1.0, 0.07], + #max_queue_ne = 4000, + #capacity_factor = 1.5, + # link_capacity = 1000, + #clear_cache_graph_freq = 5, + #pkt_per_tick = 5000, + # max_msg_live = 5, + init_sne_params = (ids=[5,9],capacity_factor=[2,2]), + init_link_params = (ids=[(2,5),(4,5),(5,8),(5,6)],capacities=Int.(ones(4)*1000)), + ntw_services = [ + (3, 6), + #(1, 4), + (9,1), + (8,4) + ] + ) + +#obtain the configuration object. This method will create the control and underlying graphs as well as other objects required to run the simulation. +cfg = NAssets.config(bcfg) + + +# run simulation +ctl_ags, vnes, modbin = NAssets.single_run(cfg,log_to_file=false) + +# Three objects are returned with the state trajectory of the control agents, network elements (assets) and the entire model + + +# Condition deterioration + +prul = plot(title="Network Assets RUL") + +for ne in 1:size(vnes,1) + plot!(prul,[ ne_st.rul for ne_st in vnes[ne] ], linestyle= ne == 2 ? :dash : :dot ) +end +prul +# hline!(p,[10], linestyle=:dash, c=:red, label="") +# hline!(p,[0.1], linestyle=:dash, c=:red, label="") + +# print(modbin) + + + +#rings +#gp = NAssets.get_graph(-1,40,NAssets.GraphModel(7);k=2,B=0) + +#grid? + +gp = NAssets.get_graph(-1,ntw_size,NAssets.GraphModel(5)) +graphplot(gp) + +# tpt_p = plot( +# ylabel!(NAssets.plot_tpt_step(rd[1].snes_ts,rd[4].snes_ts,rd[1].model_ts,t),"Throughput\n(MB/time)",guidefontsize=6) +# ,plot_tpt_step(rd[2].snes_ts,rd[4].snes_ts,rd[2].model_ts,t) +# ,plot_tpt_step(rd[3].snes_ts,rd[4].snes_ts,rd[3].model_ts,t) +# ,layout=(1,3)) + +p = plot(title="End-to-end Throughput") +for ne in 1:size(vnes,1) + plot!(p,NAssets.get_throughput_trj(vnes[ne],n_steps), linestyle= :solid , label = "Asset_$ne", legend = :outerright + ) +end +p + diff --git a/examples/example_1.jl b/examples/example_1.jl index b14ec87..28bfc48 100644 --- a/examples/example_1.jl +++ b/examples/example_1.jl @@ -1,16 +1,57 @@ using NAssets using Plots +using GraphRecipes +tst = (rul,t,a) -> begin + println("rul: $rul --- a: $a") + return last(rul) - ( a * t ) +end +ntw_size = 9 +ntw_topo = 4 +n_steps = 100 # Prepare base simulation configuration bcfg = ( - ntw_topo = 2, - size = 5, - ctl_model = 1, - n_steps = 80, - traffic_dist_params = [1.0, 0.05], - ntw_services = [(3, 5), (1, 4)] + seed = 123, + ntw_topo = ntw_topo, + size = ntw_size, + ctl_model = 7, + ctl_k = 3, + ctl_B = 0.7, + # prob_random_walks = 0.8, + n_steps = n_steps, + deterioration = [ (rul,t,a) -> rul - a 1 ], + prediction = [ tst 1 ], + traffic_dist_params = [1.0, 0.07], + traffic_packets = 100, + #max_queue_ne = 100, + #capacity_factor = 5, + link_capacity = 2000, + max_msg_live = 10, + #clear_cache_graph_freq = 5, + pkt_per_tick = 3100, + # max_msg_live = 5, + mnt_bc_duration = 1, + mnt_bc_cost = 0.5, + mnt_wc_duration = 5, + mnt_wc_cost = 5, + mnt_policy = 0, + predictive_freq = 10, + prediction_window = 10, + init_sne_params = + #(ids=[9],capacity_factor=[4]), + (ids=[9],mnt_policy=[1]), + # init_link_params = ( + # # # ids=[(2,5),(4,5),(5,8),(5,6),(1,2),(3,6),(6,9),(8,9)],capacities=[2000,4000,4000,500,4000,5000,500,500] + # ids = [(7,8)], + # capacities = [2000] + # ), + ntw_services = [ + (3, 7), + (9,1), + (8,4) + ] ) #obtain the configuration object. This method will create the control and underlying graphs as well as other objects required to run the simulation. @@ -22,13 +63,51 @@ ctl_ags, vnes, modbin = NAssets.single_run(cfg,log_to_file=false) # Three objects are returned with the state trajectory of the control agents, network elements (assets) and the entire model -# -p = plot(title="Network Assets RUL") + +# Condition deterioration + +prul = plot(title="Network Assets RUL") for ne in 1:size(vnes,1) - plot!(p,[ ne_st.rul for ne_st in vnes[ne] ], linestyle= ne == 2 ? :dash : :dot ) + plot!(prul,[ ne_st.rul for ne_st in vnes[ne] ], linestyle= ne == 2 ? :dash : :dot ) end -hline!(p,[10], linestyle=:dash, c=:red, label="") -hline!(p,[0.1], linestyle=:dash, c=:red, label="") -p +prul +hline!(prul,[10], linestyle=:dash, c=:red, label="") +prul +# hline!(p,[0.1], linestyle=:dash, c=:red, label="") + +# print(modbin) + + + +#rings +#gp = NAssets.get_graph(-1,40,NAssets.GraphModel(7);k=2,B=0) + +#grid? + +# gp = NAssets.get_graph(-1,ntw_size,NAssets.GraphModel(5)) +# graphplot(gp) + +# tpt_p = plot( +# ylabel!(NAssets.plot_tpt_step(rd[1].snes_ts,rd[4].snes_ts,rd[1].model_ts,t),"Throughput\n(MB/time)",guidefontsize=6) +# ,plot_tpt_step(rd[2].snes_ts,rd[4].snes_ts,rd[2].model_ts,t) +# ,plot_tpt_step(rd[3].snes_ts,rd[4].snes_ts,rd[3].model_ts,t) +# ,layout=(1,3)) + +# p = plot(title="End-to-end Throughput") +# for ne in 1:size(vnes,1) +# plot!(p,NAssets.get_throughput_trj(vnes[ne],n_steps), linestyle= :solid , label = "Asset_$ne", legend = :outerright +# ) +# end +# p + + + +# pls = plot(title="Packet loss") +# for ne in 1:size(vnes,1) +# plot!(pls,[ vnes[ne][i].drop_pkt for i=1:n_steps ], linestyle= :solid , label = "Asset_$ne", legend = :outerright +# ) +# end +# pls + diff --git a/src/ctl/queries_multiple.jl b/src/ctl/queries_multiple.jl index 883bd37..ce4bfb4 100644 --- a/src/ctl/queries_multiple.jl +++ b/src/ctl/queries_multiple.jl @@ -21,7 +21,7 @@ function do_query!(msg::OFMessage,a::Agent,model) path = do_query(query_time,query,query_graph,query_paths) - # log_info(model.ticks,a.id,"query: $(query) ----path found: $path ----> in precalc paths: $(query_paths)") + # log_info(model.ticks,a.id,"query: $(query) ----path found: $path ----> in precalc paths: $(query_paths) -- query graph: $(nv(query_graph)))") # For no centralised control topo if model.ctrl_model != GraphModel(1) # ¬ centralised @@ -33,7 +33,7 @@ function do_query!(msg::OFMessage,a::Agent,model) #valid path not found?, need to send queries to nbs if isempty(path) - #should always query nbs even if has already queried with no reply? + #TODO should always query nbs even if has already queried with no reply? sent_to = query_nbs!(a,msg,query_graph,query,[a.id],model) record_pending_query!(a,model.ticks,sent_to,query) push!(a.pending,(model.ticks,msg,false)) #false:not reprocess next time diff --git a/src/model/netManModel.jl b/src/model/netManModel.jl index 88dceff..f054428 100644 --- a/src/model/netManModel.jl +++ b/src/model/netManModel.jl @@ -62,6 +62,7 @@ function create_sim_asset_agents!(model) mnt_policy = typeof(model.init_sne_params) <: NamedTuple && id in model.init_sne_params.ids && Symbol("mnt_policy") in keys(model.init_sne_params) ? model.init_sne_params.mnt_policy[first(indexin(id,model.init_sne_params.ids))] : model.mnt_policy + log_info(model.ticks,"Prediction in init: $(last(prediction))") mnt = @match mnt_policy begin 1 => MaintenanceInfoPreventive(deterioration,prediction,model) 2 => MaintenanceInfoPredictive(deterioration,prediction,model) @@ -260,10 +261,9 @@ end Initialise control agents """ function init_agent!(a::Agent,model) - + nodes = sort([get_controlled_assets(a.id,model)...]) if model.ctrl_model != GraphModel(1) #Calculate sub graphs and init msg channels among agents - nodes = [get_controlled_assets(a.id,model)...] sub_g = get_subgraph(model.ntw_graph,nodes,:eid) nodes = [a.id] @@ -284,17 +284,24 @@ function init_agent!(a::Agent,model) end ## - if a.maintenance.policy != CorrectiveM - schedule_event!(a,CTL_Event(4),a.maintenance.predictive_freq,Array{Int64,1}()) - if a.maintenance.policy == PredictiveM - if Symbol("py_integration") in keys(model.properties) - #conversion to py - ajm_py = model.py_integration.np.matrix(adjacency_matrix(a.ntw_graph)) - model.py_integration.opt_init.optimisation_initialisation( ajm_py, - model.traffic_dist_params - #[1,0.05] - , model.mnt_bc_cost, model.mnt_bc_duration, model.mnt_wc_cost, model.mnt_wc_duration) - end + + snes = [ getindex(model,ca) for ca in nodes ] + + with_predictions = [ sne.id for sne in snes if sne.maintenance.policy != CorrectiveM ] + + log_info(model.ticks,a.id,"with_predictions: $(with_predictions)") + + with_py_plan = [ sne.id for sne in snes if sne.maintenance.policy == PredictiveM ] + + schedule_event!(a,CTL_Event(4),a.maintenance.predictive_freq,with_predictions) + + if !isempty(with_py_plan) + if Symbol("py_integration") in keys(model.properties) + #conversion to py + ajm_py = model.py_integration.np.matrix(adjacency_matrix(a.ntw_graph)) + model.py_integration.opt_init.optimisation_initialisation( ajm_py, + model.traffic_dist_params + , model.mnt_bc_cost, model.mnt_bc_duration, model.mnt_wc_cost, model.mnt_wc_duration) end end end diff --git a/src/phy/maintenance_model.jl b/src/phy/maintenance_model.jl index 9eb254f..c347e76 100644 --- a/src/phy/maintenance_model.jl +++ b/src/phy/maintenance_model.jl @@ -17,34 +17,6 @@ function get_next_maintenance_due(sne::SimNE,model::ABM) end -# function trigger_maintenance(sne::SimNE) -# state = get_state(sne) -# # if state.maintenance_due == model.ticks - -# # end -# end - -# """ -# It triggers maintenance when the asset is brokendown - -# """ -# function do_corrective_man(sne::SimNE) -# state = get_state(sne) -# if !state.up -# trigger_maintenance(sne) -# end -# end - -# """ -# It triggers maintenance on due date assuming is before the asset breakdown -# """ -# function do_preventive_man(sne::SimNE,model::ABM) -# state = get_state(sne) -# if state.maintenance_due == model.ticks -# trigger_maintenance(sne) -# end -# end - function init_maintenance!(sne::SimNE,model::ABM) state = get_state(sne) #init with according to factory estimated parameters @@ -60,7 +32,7 @@ It simulates start of maintenance. """ function start_mnt!(a::Agent,sne::SimNE,model::ABM) - # log_info(model.ticks,a.id,"Starting mnt... $(sne.id)") + log_info(model.ticks,a.id,"Starting mnt... $(sne.id)") sne.maintenance.job_start = model.ticks state = get_state(sne) state.up = false @@ -69,7 +41,7 @@ function start_mnt!(a::Agent,sne::SimNE,model::ABM) set_state!(sne,state) drop_node!(sne,model) finish_mnt = model.ticks + sne.maintenance.duration - # log_info(model.ticks,a.id,"schedulling up of $(sne.id) for... $(finish_mnt)") + log_info(model.ticks,a.id,"schedulling up of $(sne.id) for... $(finish_mnt)") schedule_event!(a,CTL_Event(3),finish_mnt,[sne.id]) end @@ -121,28 +93,11 @@ end function get_rul_predictions(sne::SimNE,current_time::Int64,window_size::Int64)::Vector{Float64} - rul = get_state(sne).rul - return [ first(sne.maintenance.prediction)(rul,t,last(sne.maintenance.prediction,size(sne.maintenance.prediction,2)-1)...) for t = 1 : window_size ] + rul = [ st.rul for st in sne.state_trj ] + println("rul on get rul predctions: $rul ") + return [ first(sne.maintenance.prediction)(rul,t,(last(sne.maintenance.prediction,size(sne.maintenance.prediction,2)-1)...)) for t = 1 : window_size ] end -# """ -# Do corrective maintenance activities for the assets under control of a given agent. -# """ -# function do_maintenance_step!(a::Agent,mnt_policy::Type{CorrectiveM},model::ABM) - -# sne_ids = get_controlled_assets(a.id,model) - -# for sne_id in sne_ids -# sne = getindex(model,sne_id) -# if is_start_mnt(sne,mnt_policy,model) -# start_mnt!(sne,model.ticks,mnt_policy) -# end -# if sne.maintenance.job_start > 0 && sne.maintenance.job_start + sne.maintenance.duration == model.ticks -# stop_mnt!(sne,mnt_policy,model) -# end -# end - -# end """ Schedules an event of type ``type`` on the given agent ``a`` at time ``time``, affecting the snes with ids: ``snes``. @@ -151,7 +106,7 @@ function schedule_event!(a::Agent,type::CTL_Event,time::Int64,snes::Vector{Int64 if !haskey(a.events,time) a.events[time] = Array{ControlEvent,1}() end - # log_info(time-1,a.id,"scheduled event $type at t: $time for snes: $(snes)") + log_info(time-1,a.id,"scheduled event $type at t: $time for snes: $(snes)") push!(a.events[time],ControlEvent(time,type,snes)) end @@ -166,25 +121,25 @@ end """ `update_maintenance_plan!(a::Agent,mnt_policy::Type{PreventiveM},model::ABM)` -It schedules maintenance events (start/stop maintenance) for assets under control of `a` that are configured with preventive and predictive `mnt_policy` +It schedules maintenance events (start/stop maintenance) for assets under control of `a` that are configured with preventive or predictive `mnt_policy` """ -function update_maintenance_plan!(a::Agent,mnt_policy::Type{PreventiveM},model::ABM) - # log_info(model.ticks,a.id,"Updating mnt plan for $(a.id) -- controlled snes: $(get_controlled_assets(a.id,model))...") - controlled_snes = get_controlled_assets(a.id,model) - controlled_snes_pred = [ sne for sne in getindex.([model],controlled_snes) if sne.maintenance.policy != CorrectiveM ] - sne_ids_pred = [sne.id for sne in controlled_snes_pred] +function update_maintenance_plan!(a::Agent, sne_ids_pred::Array{Int64},model::ABM) + log_info(model.ticks,a.id,"Updating mnt plan for $(a.id) ...") + window_size = a.maintenance.prediction_window #use the maintenance window from the end - window size ruls = a.rul_predictions[:,size(a.rul_predictions,2)-window_size+1:size(a.rul_predictions,2)] #mnt_plan = - # log_info(model.ticks,a.id," ruls predicted=> $ruls <==") + log_info(model.ticks,a.id," ruls predicted=> $ruls <==") for i=1:size(ruls,1) sne = getindex(model,sne_ids_pred[i]) if !get_state(sne).on_maintenance && sne.id in sne_ids_pred #sum all where rul is <= threshold, if any > 0, then sum > 0 - threshold_reached = sum(ruls[i,size(ruls,2)-window_size+1:size(ruls,2)] .<= a.maintenance.threshold) > 0 + cruls = ruls[i,size(ruls,2)-window_size+1:size(ruls,2)] + log_info(model.ticks,a.id,"cruls==>$(cruls)") + threshold_reached = sum(cruls .<= a.maintenance.threshold) > 0 if threshold_reached#!isempty(threshold_reached) #negative indicates i goes down for maintenance #1st reroute traffic out of node @@ -229,7 +184,7 @@ end """ `update_maintenance_plan!(a::Agent,mnt_policy::Type{PreventiveM},model::ABM)` -It schedules maintenance events (start/stop maintenance) for assets under control of `a` that are configured with predictive `mnt_policy` +It schedules maintenance events (start/stop maintenance) for assets under control of `a` that are configured with predictive `mnt_policy` with maintenance planning running in python. """ function update_maintenance_plan!(a::Agent,mnt_policy::Type{PredictiveM},model::ABM) @@ -249,8 +204,7 @@ function update_maintenance_plan!(a::Agent,mnt_policy::Type{PredictiveM},model:: services_py = model.py_integration.np.matrix(model.ntw_services) .- 1 ruls_py = model.py_integration.np.matrix(ruls) #pycall to optimisation function - log_info(model.ticks,a.id,"srvs=>$(services_py)") - log_info(model.ticks,a.id,"ruls_py=>$(ruls_py)") + mnt_plan, routes = model.py_integration.opt_run.maintenance_planning(model.ticks,services_py, ruls_py) end @@ -259,9 +213,7 @@ function update_maintenance_plan!(a::Agent,mnt_policy::Type{PredictiveM},model:: if size(routes,2) != size(ruls,1) + 2 routes = transpose(reshape(routes,size(ruls,1) + 2,:)) end - - # log_info(model.ticks,a.id," From optimisation algo PLAN: $(mnt_plan)") - # log_info(model.ticks,a.id," From optimisation algo=> ROUTES: $(routes)") + #convert routes from py to julia indexes routes = routes .+ 1 @@ -289,7 +241,7 @@ end It processes scheduled events """ function do_events_step!(a::Agent,model::ABM) - # log_info(model.ticks,a.id,"processing events: $(a.events) ") + log_info(model.ticks,a.id,"processing events: $(a.events) ") if haskey(a.events,model.ticks) evs = a.events[model.ticks] ntw_changes = Array{Int64,1}() @@ -313,7 +265,7 @@ function do_events_step!(a::Agent,model::ABM) stop_mnt!(a,sne,model) end CTL_Event(4) => - do_rul_predictions!(a,model) + do_rul_predictions!(a,e.snes,model) CTL_Event(5) => do_update_flows_from_path!(a,e.snes,model) @@ -334,91 +286,31 @@ end """ Run RUL predictions for the assets controlled by agent ``a`` """ -function do_rul_predictions!(a::Agent,model::ABM) +function do_rul_predictions!(a::Agent,sne_ids_pred::Array{Int64},model::ABM) window_size = a.maintenance.prediction_window * 2 - # log_info(model.ticks,a.id,"Running RUL predictions...") + log_info(model.ticks,a.id,"Running RUL predictions.. + .") #sort snes by id, works either for centralised (all assets one control agent or decentralised 1 asset per agent) #TODO decentralised with more than 1 asset per agent. - sne_ids = sort(collect(get_controlled_assets(a.id,model))) #sne_ids = collect(1:nv(a.base_ntw_graph)) - snes = [ sne for sne in getindex.([model],sne_ids) if sne.maintenance.policy != CorrectiveM ] - sne_ids_pred = [sne.id for sne in snes] - # log_info(model.ticks,a.id,"sne_ids: $(sne_ids)") + snes = [ sne for sne in getindex.([model],sne_ids_pred) ] + log_info(model.ticks,a.id,"predicting for snes: $(sne_ids_pred)") #arrange predictions in a matrix of dims: length(snes) x window_size. ruls_pred = permutedims(hcat(get_rul_predictions.(snes,[model.ticks],[window_size])...)) + log_info(model.ticks,a.id,"ruls_pred: $(ruls_pred)") + log_info(model.ticks,a.id,"rul predictions: $(a.rul_predictions)") + a.rul_predictions = length(a.rul_predictions) > 0 ? hcat(a.rul_predictions,ruls_pred) : ruls_pred # log_info(model.ticks,a.id," length: $(size(a.rul_predictions)) rul pred: $(a.rul_predictions)") # log_info(model.ticks,a.id,"Pred Maint=> services: $(model.ntw_services))") if !isempty(sne_ids_pred) - update_maintenance_plan!(a,a.maintenance.policy,model) + update_maintenance_plan!(a,sne_ids_pred,model) end #collect(get_controlled_assets(a.id,model)) #run next prediction - schedule_event!(a,CTL_Event(4),model.ticks+a.maintenance.predictive_freq) + schedule_event!(a,CTL_Event(4),model.ticks+a.maintenance.predictive_freq,sne_ids_pred) end - -""" -Do preventive maintenance activities for the assets controlled by the given agent. -""" -# function do_maintenance_step!(a::Agent,mnt_policy::Type{T},model::ABM) where T<:MaintenanceType - -# #prediction -# if model.ticks%a.maintenance.predictive_freq == 0 -# window_size = a.maintenance.prediction_window -# #sort snes by id, works either for centralised (all assets one control agent or decentralised 1 asset per agent) #TODO decentralised with more than 1 asset per agent. -# # sne_ids = sort(collect(get_controlled_assets(a.id,model))) -# sne_ids = collect(1:nv(a.params[:base_ntw_graph])) - -# snes = getindex.([model],sne_ids) - -# log_info(model.ticks,a.id,"sne_ids: $(sne_ids)") - -# #arrange predictions in a matrix of dims: length(snes) x window_size. -# ruls_pred = permutedims(hcat(get_rul_predictions.(snes,[model.ticks],[window_size])...)) -# a.rul_predictions = length(a.rul_predictions) > 0 ? hcat(a.rul_predictions,ruls_pred) : ruls_pred -# # log_info(model.ticks,a.id," length: $(size(a.rul_predictions)) rul pred: $(a.rul_predictions)") -# log_info(model.ticks,a.id,"Pred Maint=> services: $(model.ntw_services))") - -# update_maintenance_plan!(a,mnt_policy,model) -# end - -# #check a.pending_jobs if any job for the current tick, if so start -# ntw_changes::Vector{Int64} = [] -# if haskey(a.maintenance.pending_jobs_start,model.ticks) -# for nid in a.maintenance.pending_jobs_start[model.ticks] -# push!(ntw_changes,-1 * nid ) -# sne = getindex(model,nid) -# start_mnt!(sne,model.ticks) -# end -# delete!(a.maintenance.pending_jobs_start,model.ticks) -# end - -# if haskey(a.maintenance.pending_jobs_stop,model.ticks) -# for nid in a.maintenance.pending_jobs_stop[model.ticks] -# push!(ntw_changes,nid) -# sne = getindex(model,nid) -# stop_mnt!(sne) -# end -# delete!(a.maintenance.pending_jobs_stop,model.ticks) -# end - -# if !isempty(ntw_changes) -# do_update_flows!(a,ntw_changes,model) -# end - -# ##create ag message for predicted nes down - -# #check duration against job start -# #for stop -# ## create message for predicted nes_down? (should be renamed) -# ## retrigger query and install of paths with maintained assets - -# end - - - - function is_start_mnt(sne::SimNE,mnt_policy::Type{CorrectiveM},model::ABM) return !get_state(sne).up && !get_state(sne).on_maintenance end @@ -433,19 +325,19 @@ end function MaintenanceInfoCorrective(deterioration::Array{Any},prediction::Array{Any},model) # TODO adjust to multiple eul. For time being, always 100. - return MaintenanceInfo(CorrectiveM,100,-1,model.mnt_wc_duration,model.mnt_wc_cost,0.1,prediction,0,0,deterioration,model.mnt_wc_duration,model.mnt_wc_cost) + return MaintenanceInfo(CorrectiveM,100,-1,model.mnt_wc_duration,model.mnt_wc_cost,0.1,prediction,model.predictive_freq,model.prediction_window,deterioration,model.mnt_wc_duration,model.mnt_wc_cost) end function MaintenanceInfoCorrective(model) MaintenanceInfoCorrective([],[],model) end function MaintenanceInfoPreventive(deterioration::Array{Any},prediction::Array{Any},model) - return MaintenanceInfo(PreventiveM,100,-1,model.mnt_bc_duration,model.mnt_bc_cost,10.,prediction,10,10,deterioration,model.mnt_bc_duration,model.mnt_bc_cost) + return MaintenanceInfo(PreventiveM,100,-1,model.mnt_bc_duration,model.mnt_bc_cost,10.,prediction,model.predictive_freq,model.prediction_window,deterioration,model.mnt_bc_duration,model.mnt_bc_cost) end function MaintenanceInfoPreventive(model) MaintenanceInfoPreventive([],[],model) end function MaintenanceInfoPredictive(deterioration::Array{Any},prediction::Array{Any},model) - return MaintenanceInfo(PredictiveM,100,-1,model.mnt_bc_duration,model.mnt_bc_cost,20.,prediction,10,10,deterioration,model.mnt_bc_duration,model.mnt_bc_cost) + return MaintenanceInfo(PredictiveM,100,-1,model.mnt_bc_duration,model.mnt_bc_cost,20.,prediction,model.predictive_freq,model.prediction_window,deterioration,model.mnt_bc_duration,model.mnt_bc_cost) end function MaintenanceInfoPredictive(model) MaintenanceInfoPredictive([],[],model) diff --git a/src/utils/running_functions.jl b/src/utils/running_functions.jl index 4c5a1b7..0486ed5 100644 --- a/src/utils/running_functions.jl +++ b/src/utils/running_functions.jl @@ -202,6 +202,8 @@ function get_default_config() deterioration = [ (rul,t,a) -> rul - a 0.0 ], # deterioration parameters for network assets. This parameter is used by the `deteriorate!` function in the `physical_model` module. prediction = [ (rul,t,a) -> rul - a 0.0 ], # Function used to predict rul of the assets. Default equal to deterioration. + predictive_freq = 0, # Frequency for running predictions + prediction_window = 0, # How many time steps ahead the prediction to run the prediction mnt_policy = 0, # Maintenance policy used in the simulation. 0: Corrective, 1: Preventive, 2: Custom/Optimal mnt_wc_duration = 0, # Worst case duration of the maintenance operations (ticks) mnt_bc_duration = 0, # Best case duration of the maintenance operations (ticks)