Sha256: 598314f0b346eb0a7e57c2017ad9bbbf5e93fd1acdca935179f316e415814d3a

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

# *******************************************************************************
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
# See also https://openstudio.net/license
# *******************************************************************************

# OpenStudio::Analysis::Algorithm define the algorithm parameters. The module and class names start to conflict
# with OpenStudio's namespace. Be careful adding new classes without first making sure that the namespace conflict
# is clear.
module OpenStudio
  module Analysis
    class AlgorithmAttributes
      # Create a new instance of the parameters for an algorithm 
      #
      def initialize
        @attributes = {
        "seed": nil,
        "failed_f_value": 1000000000000000000,
        "debug_messages": 1
        }
      end

      # these are the allowed analysis types
      ANALYSIS_TYPES = ['diag', 'doe', 'fast99', 'ga', 'gaisl', 'lhs', 'morris', 'nsga_nrel', 'optim',
                        'preflight', 'pso', 'repeat_run', 'rgenoud', 'single_run', 'sobol', 'spea_nrel']

      def set_attribute(attribute_name, attribute_value)
        @attributes[attribute_name] = attribute_value
        begin
          unless Float(attribute_value).nil?
            if Float(attribute_value).abs >= Float('1.0e+19')
              raise "ERROR: Attribute `#{attribute_name}` is greater than 1E19. This may cause failures."
            end
          end
        rescue ArgumentError, TypeError
        end
      end

      def [](name)
        @attributes[name]
      end

      def to_hash(_version = 1)
        @attributes
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openstudio-analysis-1.3.5 lib/openstudio/analysis/algorithm_attributes.rb
openstudio-analysis-1.3.4 lib/openstudio/analysis/algorithm_attributes.rb