packages/engine/scram-node/src/settings.h
Builder for settings.
Namespaces
| Name |
|---|
| scram |
| scram::core |
Classes
| Name | |
|---|---|
| class | scram::core::Settings <br>Builder for analysis settings. |
Source code
cpp
/*
* Copyright (C) 2014-2018 Olzhas Rakhimov
* Copyright (C) 2023 OpenPRA ORG Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <cstdint>
#include <string_view>
namespace scram::core {
enum class Algorithm : std::uint8_t { kBdd = 0, kZbdd, kMocus };
const char* const kAlgorithmToString[] = {"bdd", "zbdd", "mocus"};
enum class Approximation : std::uint8_t { kNone = 0, kRareEvent, kMcub };
const char* const kApproximationToString[] = {"none", "rare-event", "mcub"};
class Settings {
public:
Algorithm algorithm() const { return algorithm_; }
Settings& algorithm(Algorithm value) noexcept;
Settings& algorithm(std::string_view value);
Approximation approximation() const { return approximation_; }
Settings& approximation(Approximation value);
Settings& approximation(std::string_view value);
bool prime_implicants() const { return prime_implicants_; }
Settings& prime_implicants(bool flag);
int limit_order() const { return limit_order_; }
Settings& limit_order(int order);
double cut_off() const { return cut_off_; }
Settings& cut_off(double prob);
int num_trials() const { return num_trials_; }
Settings& num_trials(int n);
int num_quantiles() const { return num_quantiles_; }
Settings& num_quantiles(int n);
int num_bins() const { return num_bins_; }
Settings& num_bins(int n);
int seed() const { return seed_; }
Settings& seed(int s);
double mission_time() const { return mission_time_; }
Settings& mission_time(double time);
double time_step() const { return time_step_; }
Settings& time_step(double time);
bool probability_analysis() const { return probability_analysis_; }
Settings& probability_analysis(bool flag) {
if (!importance_analysis_ && !uncertainty_analysis_ &&
!safety_integrity_levels_) {
probability_analysis_ = flag;
}
return *this;
}
bool safety_integrity_levels() const { return safety_integrity_levels_; }
Settings& safety_integrity_levels(bool flag);
bool importance_analysis() const { return importance_analysis_; }
Settings& importance_analysis(bool flag) {
importance_analysis_ = flag;
if (importance_analysis_)
probability_analysis_ = true;
return *this;
}
bool uncertainty_analysis() const { return uncertainty_analysis_; }
Settings& uncertainty_analysis(bool flag) {
uncertainty_analysis_ = flag;
if (uncertainty_analysis_)
probability_analysis_ = true;
return *this;
}
bool ccf_analysis() const { return ccf_analysis_; }
Settings& ccf_analysis(bool flag) {
ccf_analysis_ = flag;
return *this;
}
#ifndef NDEBUG
bool preprocessor = false;
bool print = false;
#endif
private:
bool probability_analysis_ = false;
bool safety_integrity_levels_ = false;
bool importance_analysis_ = false;
bool uncertainty_analysis_ = false;
bool ccf_analysis_ = false;
bool prime_implicants_ = false;
Algorithm algorithm_ = Algorithm::kBdd;
Approximation approximation_ = Approximation::kNone;
int limit_order_ = 20;
int seed_ = 0;
int num_trials_ = 1e3;
int num_quantiles_ = 20;
int num_bins_ = 20;
double mission_time_ = 8760;
double time_step_ = 0;
double cut_off_ = 1e-8;
};
} // namespace scram::coreUpdated on 2025-11-11 at 16:51:09 +0000
