Class: URBANopt::Scenario::ScenarioBase

Inherits:
Object
  • Object
show all
Defined in:
lib/urbanopt/scenario/scenario_base.rb

Overview

ScenarioBase is a simulation method agnostic description of a Scenario.

Direct Known Subclasses

ScenarioCSV

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, root_dir, run_dir, feature_file) ⇒ ScenarioBase

Initialize ScenarioBase attributes: name , root directory , run directory and feature_file

parameters:
  • name - String - Human readable scenario name.

  • root_dir - String - Root directory for the scenario, contains Gemfile describing dependencies.

  • run_dir - String - Directory for simulation of this scenario, deleting run directory clears the scenario.

  • feature_file - FeatureFile - An instance of URBANopt::Core::FeatureFile containing features for simulation.



53
54
55
56
57
58
# File 'lib/urbanopt/scenario/scenario_base.rb', line 53

def initialize(name, root_dir, run_dir, feature_file)
  @name = name
  @root_dir = root_dir
  @run_dir = run_dir
  @feature_file = feature_file
end

Instance Attribute Details

#feature_fileObject (readonly)

An instance of URBANopt::Core::FeatureFile associated with this Scenario.



74
75
76
# File 'lib/urbanopt/scenario/scenario_base.rb', line 74

def feature_file
  @feature_file
end

#nameObject (readonly)

Name of the Scenario.



62
63
64
# File 'lib/urbanopt/scenario/scenario_base.rb', line 62

def name
  @name
end

#root_dirObject (readonly)

Root directory containing Gemfile.



66
67
68
# File 'lib/urbanopt/scenario/scenario_base.rb', line 66

def root_dir
  @root_dir
end

#run_dirObject (readonly)

Directory to run this Scenario.



70
71
72
# File 'lib/urbanopt/scenario/scenario_base.rb', line 70

def run_dir
  @run_dir
end

Instance Method Details

#clearObject

Removes all simulation input and output files by removing this Scenario’s run_dir .



82
83
84
85
86
# File 'lib/urbanopt/scenario/scenario_base.rb', line 82

def clear
  Dir.glob(File.join(@run_dir, '/*')).each do |f|
    FileUtils.rm_rf(f)
  end
end

#simulation_dirsObject

An array of SimulationDirBase objects.



77
78
79
# File 'lib/urbanopt/scenario/scenario_base.rb', line 77

def simulation_dirs
  raise 'simulation_dirs not implemented for ScenarioBase, override in your class'
end