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.



18
19
20
21
22
23
# File 'lib/urbanopt/scenario/scenario_base.rb', line 18

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.



39
40
41
# File 'lib/urbanopt/scenario/scenario_base.rb', line 39

def feature_file
  @feature_file
end

#nameObject (readonly)

Name of the Scenario.



27
28
29
# File 'lib/urbanopt/scenario/scenario_base.rb', line 27

def name
  @name
end

#root_dirObject (readonly)

Root directory containing Gemfile.



31
32
33
# File 'lib/urbanopt/scenario/scenario_base.rb', line 31

def root_dir
  @root_dir
end

#run_dirObject (readonly)

Directory to run this Scenario.



35
36
37
# File 'lib/urbanopt/scenario/scenario_base.rb', line 35

def run_dir
  @run_dir
end

Instance Method Details

#clearObject

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



47
48
49
50
51
# File 'lib/urbanopt/scenario/scenario_base.rb', line 47

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

#simulation_dirsObject

An array of SimulationDirBase objects.



42
43
44
# File 'lib/urbanopt/scenario/scenario_base.rb', line 42

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