Subversion Repositories OpenSees

Compare Revisions

Ignore whitespace Rev 290 → Rev 291

/trunk/SRC/reliability/tcl/TclReliabilityBuilder.cpp
1,1816 → 1,1816
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.3 $
// $Date: 2001-06-14 08:00:27 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/tcl/TclReliabilityBuilder.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <stdlib.h>
#include <string.h>
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
 
#include <Matrix.h>
#include <Vector.h>
#include <ID.h>
#include <ArrayOfTaggedObjects.h>
 
#include <Domain.h>
 
#include <ReliabilityDomain.h>
#include <RandomVariable.h>
#include <CorrelationCoefficient.h>
#include <LimitStateFunction.h>
#include <RandomVariablePositioner.h>
#include <NormalRV.h>
#include <LognormalRV.h>
#include <GammaRV.h>
#include <ShiftedExponentialRV.h>
#include <ShiftedRayleighRV.h>
#include <ExponentialRV.h>
#include <RayleighRV.h>
#include <UniformRV.h>
#include <BetaRV.h>
#include <Type1LargestValueRV.h>
#include <Type1SmallestValueRV.h>
#include <Type2LargestValueRV.h>
#include <Type3SmallestValueRV.h>
#include <ChiSquareRV.h>
#include <GumbelRV.h>
#include <WeibullRV.h>
#include <LaplaceRV.h>
#include <ParetoRV.h>
#include <GFunEvaluator.h>
#include <SensitivityEvaluator.h>
#include <StepSizeRule.h>
#include <SearchDirection.h>
#include <XuTransformation.h>
#include <NatafXuTransformation.h>
#include <FindDesignPoint.h>
#include <ReliabilityAnalysis.h>
#include <HLRFSearchDirection.h>
#include <ArmijoRule.h>
#include <FixedStepSizeRule.h>
#include <OpenSeesGFunEvaluator.h>
#include <OpenSeesSensitivityEvaluator.h>
#include <BasicGFunEvaluator.h>
#include <SensitivityByFiniteDifference.h>
#include <SensitivityByFiniteDifference.h>
#include <SearchWithStepSizeAndStepDirection.h>
#include <FORMAnalysis.h>
#include <SimulationAnalysis.h>
#include <RandomNumberGenerator.h>
#include <CStdLibRandGenerator.h>
#include <FindCurvatures.h>
#include <FirstPrincipalCurvature.h>
#include <CurvaturesBySearchAlgorithm.h>
#include <SORMAnalysis.h>
#include <SystemAnalysis.h>
 
 
#include <TclReliabilityBuilder.h>
 
//
// SOME STATIC POINTERS USED IN THE FUNCTIONS INVOKED BY THE INTERPRETER
//
static ReliabilityDomain *theReliabilityDomain = 0;
static Domain *theStructuralDomain = 0;
 
static GFunEvaluator *theGFunEvaluator = 0;
static SensitivityEvaluator *theSensitivityEvaluator = 0;
static StepSizeRule *theStepSizeRule = 0;
static SearchDirection *theSearchDirection = 0;
static XuTransformation *theXuTransformation = 0;
static RandomNumberGenerator *theRandomNumberGenerator = 0;
static FindDesignPoint *theFindDesignPoint = 0;
static FindCurvatures *theFindCurvatures = 0;
static ReliabilityAnalysis *theFORMAnalysis = 0;
static ReliabilityAnalysis *theSORMAnalysis = 0;
static ReliabilityAnalysis *theSimulationAnalysis = 0;
static SystemAnalysis *theSystemAnalysis = 0;
 
//
// THE PROTOTYPES OF THE FUNCTIONS INVOKED BY THE INTERPRETER
//
int TclReliabilityModelBuilder_addRandomVariable(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addCorrelate(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addLimitState(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addRandomVariablePositioner(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addXuTransformation(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addRandomNumberGenerator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addSearchDirection(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addStepSizeRule(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addgFunEvaluator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addSensitivityEvaluator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addFindDesignPoint(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addFindCurvatures(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addFORMAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addSORMAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addSystemAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addSimulationAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_analyzeReliability(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
 
 
 
//
// CLASS CONSTRUCTOR & DESTRUCTOR
//
 
// constructor: the constructor will add certain commands to the interpreter
TclReliabilityBuilder::TclReliabilityBuilder(Domain &passedDomain, Tcl_Interp *interp)
{
 
// call Tcl_CreateCommand for class specific commands
Tcl_CreateCommand(interp, "randomVariable", TclReliabilityModelBuilder_addRandomVariable,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "correlate", TclReliabilityModelBuilder_addCorrelate,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "limitState", TclReliabilityModelBuilder_addLimitState,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "randomVariablePositioner",
TclReliabilityModelBuilder_addRandomVariablePositioner,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "findDesignPoint", TclReliabilityModelBuilder_addFindDesignPoint,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "gFunEvaluator", TclReliabilityModelBuilder_addgFunEvaluator,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "sensitivityEvaluator",
TclReliabilityModelBuilder_addSensitivityEvaluator,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "stepSizeRule",
TclReliabilityModelBuilder_addStepSizeRule,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "searchDirection", TclReliabilityModelBuilder_addSearchDirection,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "xuTransformation", TclReliabilityModelBuilder_addXuTransformation,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "findCurvatures", TclReliabilityModelBuilder_addFindCurvatures,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "randomNumberGenerator",
TclReliabilityModelBuilder_addRandomNumberGenerator,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "addFORMAnalysis",TclReliabilityModelBuilder_addFORMAnalysis,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "addSORMAnalysis",TclReliabilityModelBuilder_addSORMAnalysis,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "addSystemAnalysis",TclReliabilityModelBuilder_addSystemAnalysis,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "addSimulationAnalysis",
TclReliabilityModelBuilder_addSimulationAnalysis,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "analyzeReliability",
TclReliabilityModelBuilder_analyzeReliability,
(ClientData)NULL, NULL);
 
 
// set the static pointers in this file
theStructuralDomain = &passedDomain;
theReliabilityDomain = new ReliabilityDomain();
 
// ResultsContainer *theResultsContainer = new ResultsContainer();
// theReliabilityDomain->addResultsContainer(theResultsContainer);
 
}
 
TclReliabilityBuilder::~TclReliabilityBuilder()
{
cerr << "Terje needs to write code: TclReliabilityBuilder::~TclReliabilityBuilder()\n";
}
 
 
//
// CLASS METHODS
//
 
/*
int
TclReliabilityBuilder::buildFE_Model(void)
{
// does nothing
return 0;
}
*/
 
ReliabilityDomain *
TclReliabilityBuilder::getReliabilityDomain()
{
return theReliabilityDomain;
}
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addRandomVariable(ClientData clientData,Tcl_Interp *interp,int argc,char **argv)
{
RandomVariable *theRandomVariable = 0;
int tag;
double mean;
double stdv;
double startPt;
double parameter1;
double parameter2;
double parameter3;
double parameter4;
int numberOfArguments = argc;
 
if (numberOfArguments==5) { // (Use mean/stdv WITHOUT startPt)
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &mean) != TCL_OK) {
cerr << "WARNING invalid input: mean \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &stdv) != TCL_OK) {
cerr << "WARNING invalid input: stdv \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"normal") == 0) {
theRandomVariable = new NormalRV(tag, mean, stdv);
}
else if (strcmp(argv[1],"lognormal") == 0) {
if (mean < 0.0 || stdv < 0.0) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LognormalRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"gamma") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GammaRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"shiftedExponential") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedExponentialRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"shiftedRayleigh") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedRayleighRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"exponential") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ExponentialRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"rayleigh") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new RayleighRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"uniform") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new UniformRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"beta") == 0) {
cerr << "WARNING: 'Beta' type random variable: use parameters to create!\n";
}
else if (strcmp(argv[1],"type1LargestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1LargestValueRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"type1SmallestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1SmallestValueRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"type2LargestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type2LargestValueRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"type3SmallestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type3SmallestValueRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"chiSquare") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ChiSquareRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"gumbel") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GumbelRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"weibull") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new WeibullRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"laplace") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LaplaceRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"pareto") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ParetoRV(tag, mean, stdv);
}
}
else {
cerr << "WARNING unrecognized type of random variable \n";
cerr << "random variable: " << tag << endl;
}
 
if (theRandomVariable == 0) {
cerr << "WARNING could not create random variable" << tag << endl;
return TCL_ERROR;
}
}
 
if (numberOfArguments==6) { // (Use mean/stdv AND startPt)
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &mean) != TCL_OK) {
cerr << "WARNING invalid input: mean \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &stdv) != TCL_OK) {
cerr << "WARNING invalid input: stdv \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[5], &startPt) != TCL_OK) {
cerr << "WARNING invalid input: startPt \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"normal") == 0) {
theRandomVariable = new NormalRV(tag, mean, stdv, startPt);
}
else if (strcmp(argv[1],"lognormal") == 0) {
if (mean < 0.0 || stdv < 0.0) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LognormalRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"gamma") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GammaRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"shiftedExponential") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedExponentialRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"shiftedRayleigh") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedRayleighRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"exponential") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ExponentialRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"rayleigh") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new RayleighRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"uniform") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new UniformRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"beta") == 0) {
cerr << "WARNING: 'Beta' type random variable: use parameters to create!\n";
}
else if (strcmp(argv[1],"type1LargestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1LargestValueRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"type1SmallestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1SmallestValueRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"type2LargestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type2LargestValueRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"type3SmallestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type3SmallestValueRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"chiSquare") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ChiSquareRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"gumbel") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GumbelRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"weibull") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new WeibullRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"laplace") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LaplaceRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"pareto") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ParetoRV(tag, mean, stdv, startPt);
}
}
else {
cerr << "WARNING unrecognized type of random variable \n";
cerr << "random variable: " << tag << endl;
}
 
if (theRandomVariable == 0) {
cerr << "WARNING could not create random variable" << tag << endl;
return TCL_ERROR;
}
}
 
if (numberOfArguments==7) { // (Use parameters WITHOUT startPt)
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &parameter1) != TCL_OK) {
cerr << "WARNING invalid input: parameter1 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &parameter2) != TCL_OK) {
cerr << "WARNING invalid input: parameter2 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[5], &parameter3) != TCL_OK) {
cerr << "WARNING invalid input: parameter3 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[6], &parameter4) != TCL_OK) {
cerr << "WARNING invalid input: parameter4 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"normal") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new NormalRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"lognormal") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LognormalRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"gamma") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GammaRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"shiftedExponential") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedExponentialRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"shiftedRayleigh") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedRayleighRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"exponential") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ExponentialRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"rayleigh") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new RayleighRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"uniform") == 0) {
if ( parameter1 >= parameter2 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new UniformRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"beta") == 0) {
if ( parameter1 >= parameter2 || parameter3 <= 0.0 || parameter4 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new BetaRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"type1LargestValue") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1LargestValueRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"type1SmallestValue") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1SmallestValueRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"type2LargestValue") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type2LargestValueRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"type3SmallestValue") == 0) {
if ( parameter2 <= 0.0 || parameter3 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type3SmallestValueRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"chiSquare") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ChiSquareRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"gumbel") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GumbelRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"weibull") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new WeibullRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"laplace") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LaplaceRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"pareto") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ParetoRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else {
cerr << "WARNING unrecognized type of random variable \n";
cerr << "random variable: " << tag << endl;
}
 
if (theRandomVariable == 0) {
cerr << "WARNING could not create random variable" << tag << endl;
return TCL_ERROR;
}
}
 
 
if (numberOfArguments==8) { // (Use parameters AND startPt)
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &parameter1) != TCL_OK) {
cerr << "WARNING invalid input: parameter1 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &parameter2) != TCL_OK) {
cerr << "WARNING invalid input: parameter2 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[5], &parameter3) != TCL_OK) {
cerr << "WARNING invalid input: parameter3 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[6], &parameter4) != TCL_OK) {
cerr << "WARNING invalid input: parameter4 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[7], &startPt) != TCL_OK) {
cerr << "WARNING invalid input: startPt \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"normal") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new NormalRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"lognormal") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LognormalRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"gamma") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GammaRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"shiftedExponential") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedExponentialRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"shiftedRayleigh") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedRayleighRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"exponential") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ExponentialRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"rayleigh") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new RayleighRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"uniform") == 0) {
if ( parameter1 >= parameter2 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new UniformRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"beta") == 0) {
if ( parameter1 >= parameter2 || parameter3 <= 0.0 || parameter4 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new BetaRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"type1LargestValue") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1LargestValueRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"type1SmallestValue") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1SmallestValueRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"type2LargestValue") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type2LargestValueRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"type3SmallestValue") == 0) {
if ( parameter2 <= 0.0 || parameter3 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type3SmallestValueRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"chiSquare") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ChiSquareRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"gumbel") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GumbelRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"weibull") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new WeibullRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"laplace") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LaplaceRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"pareto") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ParetoRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else {
cerr << "WARNING unrecognized type of random variable \n";
cerr << "random variable: " << tag << endl;
}
 
if (theRandomVariable == 0) {
cerr << "WARNING could not create random variable" << tag << endl;
return TCL_ERROR;
}
}
 
 
// ADD THE OBJECT TO THE DOMAIN
if (theReliabilityDomain->addRandomVariable(theRandomVariable) == false) {
cerr << "WARNING failed to add random variable to the domain (wrong number of arguments?)\n";
cerr << "random variable: " << tag << endl;
delete theRandomVariable; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
}
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addCorrelate(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
CorrelationCoefficient *theCorrelationCoefficient = 0;
int tag;
int rv1;
int rv2;
double correlationValue;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[1], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &rv1) != TCL_OK) {
cerr << "WARNING invalid input: rv1 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[3], &rv2) != TCL_OK) {
cerr << "WARNING invalid input: rv2 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &correlationValue) != TCL_OK) {
cerr << "WARNING invalid input: correlationValue \n";
return TCL_ERROR;
}
 
// CREATE THE OBJECT
theCorrelationCoefficient = new CorrelationCoefficient(tag, rv1, rv2, correlationValue);
 
if (theCorrelationCoefficient == 0) {
cerr << "WARNING ran out of memory creating correlation coefficient \n";
cerr << "correlation coefficient: " << tag << endl;
return TCL_ERROR;
}
 
// ADD THE OBJECT TO THE DOMAIN
if (theReliabilityDomain->addCorrelationCoefficient(theCorrelationCoefficient) == false) {
cerr << "WARNING failed to add correlation coefficient to the domain\n";
cerr << "correlation coefficient: " << tag << endl;
delete theCorrelationCoefficient; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addLimitState(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
LimitStateFunction *theLimitStateFunction = 0;
int tag;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[1], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
// CREATE THE OBJECT (passing on argv[2])
theLimitStateFunction = new LimitStateFunction(tag, argv[2]);
if (theLimitStateFunction == 0) {
cerr << "WARNING ran out of memory creating limit-state function \n";
cerr << "limit-state function: " << tag << endl;
return TCL_ERROR;
}
 
// ADD THE OBJECT TO THE DOMAIN
if (theReliabilityDomain->addLimitStateFunction(theLimitStateFunction) == false) {
cerr << "WARNING failed to add limit-state function to the domain\n";
cerr << "limit-state function: " << tag << endl;
delete theLimitStateFunction; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
 
 
 
 
/*
 
LimitStateFunction *theLimitStateFunction = 0;
int tag;
int node;
int dof;
double displacementLimit;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[3], &node) != TCL_OK) {
cerr << "WARNING invalid input: node \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[4], &dof) != TCL_OK) {
cerr << "WARNING invalid input: dof \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[5], &displacementLimit) != TCL_OK) {
cerr << "WARNING invalid input: displacementLimit \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"disp") == 0) {
theLimitStateFunction = new LimitStateFunction(tag, node, dof, displacementLimit);
}
else {
cerr << "WARNING unrecognized type of limit-state function \n";
cerr << "limit-state function: " << tag << endl;
}
 
if (theLimitStateFunction == 0) {
cerr << "WARNING ran out of memory creating limit-state function \n";
cerr << "limit-state function: " << tag << endl;
return TCL_ERROR;
}
 
// ADD THE OBJECT TO THE DOMAIN
if (theReliabilityDomain->addLimitStateFunction(theLimitStateFunction) == false) {
cerr << "WARNING failed to add limit-state function to the domain\n";
cerr << "limit-state function: " << tag << endl;
delete theLimitStateFunction; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
*/
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addRandomVariablePositioner(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
RandomVariablePositioner *theRandomVariablePositioner = 0;
int tag;
int rvNumber;
int tagOfObject;
DomainComponent *theObject;
 
 
// READ THE TAG NUMBER
if (Tcl_GetInt(interp, argv[1], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// READ THE RANDOM VARIABLE NUMBER
if (Tcl_GetInt(interp, argv[2], &rvNumber) != TCL_OK) {
cerr << "WARNING invalid input: rvNumber \n";
return TCL_ERROR;
}
 
// IF UNCERTAIN *ELEMENT* PROPERTY
if (strcmp(argv[3],"element") == 0) {
 
if (Tcl_GetInt(interp, argv[4], &tagOfObject) != TCL_OK) {
cerr << "WARNING invalid input: tagOfObject \n";
return TCL_ERROR;
}
 
theObject = (DomainComponent *)theStructuralDomain->getElement(tagOfObject);
 
char *description[2];
description[0] = argv[5];
description[1] = argv[6];
 
theRandomVariablePositioner = new RandomVariablePositioner(tag,rvNumber,theObject,description,0);
}
 
 
// IF UNCERTAIN *LOAD*
else if (strcmp(argv[3],"loadPattern") == 0) {
 
if (Tcl_GetInt(interp, argv[4], &tagOfObject) != TCL_OK) {
cerr << "WARNING invalid input: tagOfObject \n";
return TCL_ERROR;
}
theObject = (DomainComponent *)theStructuralDomain->getLoadPattern(tagOfObject);
 
char *description[3];
description[0] = argv[5];
description[1] = argv[6];
description[2] = argv[7];
 
theRandomVariablePositioner = new RandomVariablePositioner(tag,rvNumber,theObject,description,0);
}
 
 
// ADD THE RANDOMVARIABLEPOSITIONER TO THE DOMAIN
if (theReliabilityDomain->addRandomVariablePositioner(theRandomVariablePositioner) == false) {
cerr << "WARNING failed to add random variable identificator to the domain\n";
cerr << "randomvariableID: " << tag << endl;
delete theRandomVariablePositioner; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
 
 
 
 
 
 
 
/*
// THE OLD VERSION OF THIS FUNCTION:
 
RandomVariablePositioner *theRandomVariablePositioner = 0;
int tag;
int rvNumber;
int typeOfObject;
int tagOfObject;
int typeOfParameterInObject;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[1], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &rvNumber) != TCL_OK) {
cerr << "WARNING invalid input: rvNumber \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[3], &typeOfObject) != TCL_OK) {
cerr << "WARNING invalid input: typeOfObject \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[4], &tagOfObject) != TCL_OK) {
cerr << "WARNING invalid input: tagOfObject \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[5], &typeOfParameterInObject) != TCL_OK) {
cerr << "WARNING invalid input: typeOfParameterInObject \n";
return TCL_ERROR;
}
 
 
// CREATE THE OBJECT
theRandomVariablePositioner = new RandomVariablePositioner(tag, rvNumber, typeOfObject, tagOfObject, typeOfParameterInObject);
 
if (theRandomVariablePositioner == 0) {
cerr << "WARNING ran out of memory creating random variable identificator \n";
cerr << "randomVariableID: " << tag << endl;
return TCL_ERROR;
}
 
// ADD THE OBJECT TO THE DOMAIN
if (theReliabilityDomain->addRandomVariablePositioner(theRandomVariablePositioner) == false) {
cerr << "WARNING failed to add random variable identificator to the domain\n";
cerr << "randomvariableID: " << tag << endl;
delete theRandomVariablePositioner; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
*/
}
 
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addRandomNumberGenerator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"CStdLibRandGenerator") == 0) {
theRandomNumberGenerator = new CStdLibRandGenerator();
}
else {
cerr << "WARNING unrecognized type of RandomNumberGenerator \n";
return TCL_ERROR;
}
 
if (theRandomNumberGenerator == 0) {
cerr << "WARNING could not create theRandomNumberGenerator \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addXuTransformation(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"NatafXuTransformation") == 0) {
theXuTransformation = new NatafXuTransformation(theReliabilityDomain);
}
else {
cerr << "WARNING unrecognized type of XuTransformation \n";
return TCL_ERROR;
}
 
if (theXuTransformation == 0) {
cerr << "WARNING could not create theXuTransformation \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addSearchDirection(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"HLRFSearchDirection") == 0) {
theSearchDirection = new HLRFSearchDirection();
}
else {
cerr << "WARNING unrecognized type of SearchDirection \n";
return TCL_ERROR;
}
 
if (theSearchDirection == 0) {
cerr << "WARNING could not create theSearchDirection \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addStepSizeRule(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"ArmijoRule") == 0) {
// Check that the necessary ingredients are present
if (theGFunEvaluator == 0 ) {
cerr << "Need theGFunEvaluator before a ArmijoRule can be created" << endl;
return TCL_ERROR;
}
if (theGFunEvaluator == 0 ) {
cerr << "Need theXuTransformation before a ArmijoRule can be created" << endl;
return TCL_ERROR;
}
 
theStepSizeRule = new ArmijoRule(theGFunEvaluator,theXuTransformation);
}
else if (strcmp(argv[1],"FixedStepSizeRule") == 0) {
 
double stepSize;
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[2], &stepSize) != TCL_OK) {
cerr << "WARNING invalid input: stepSize \n";
return TCL_ERROR;
}
 
theStepSizeRule = new FixedStepSizeRule(stepSize);
}
else {
cerr << "WARNING unrecognized type of StepSizeRule \n";
return TCL_ERROR;
}
 
if (theStepSizeRule == 0) {
cerr << "WARNING could not create theStepSizeRule \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addgFunEvaluator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"OpenSeesGFunEvaluator") == 0) {
 
int numIter;
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &numIter) != TCL_OK) {
cerr << "WARNING invalid input: numIter \n";
return TCL_ERROR;
}
 
theGFunEvaluator = new OpenSeesGFunEvaluator(numIter, interp, theReliabilityDomain);
}
else if (strcmp(argv[1],"BasicGFunEvaluator") == 0) {
theGFunEvaluator = new BasicGFunEvaluator(interp, theReliabilityDomain);
}
else {
cerr << "WARNING unrecognized type of GFunEvaluator \n";
return TCL_ERROR;
}
if (theGFunEvaluator == 0) {
cerr << "WARNING could not create the theGFunEvaluator \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addSensitivityEvaluator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"SensitivityByFiniteDifference") == 0) {
 
// Check that the necessary ingredients are present
if (theGFunEvaluator == 0 ) {
cerr << "Need theGFunEvaluator before a SensitivityByFiniteDifference can be created" << endl;
return TCL_ERROR;
}
 
theSensitivityEvaluator = new SensitivityByFiniteDifference(theGFunEvaluator, theReliabilityDomain);
}
else if (strcmp(argv[1],"OpenSeesSensitivityEvaluator") == 0) {
 
theSensitivityEvaluator = new OpenSeesSensitivityEvaluator(interp, theReliabilityDomain);
}
else {
cerr << "WARNING unrecognized type of SensitivityEvaluator \n";
return TCL_ERROR;
}
 
if (theSensitivityEvaluator == 0) {
cerr << "WARNING could not create theSensitivityEvaluator \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addFindCurvatures(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"onlyFirstPrincipal") == 0) {
 
theFindCurvatures = new FirstPrincipalCurvature();
}
else if (strcmp(argv[1],"bySearchAlgorithm") == 0) {
 
// Check that the necessary ingredients are present
if (theFindDesignPoint == 0 ) {
cerr << "Need theFindDesignPoint before a CurvaturesBySearchAlgorithm can be created" << endl;
return TCL_ERROR;
}
 
int numberOfCurvatures;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &numberOfCurvatures) != TCL_OK) {
cerr << "WARNING invalid input: numberOfCurvatures \n";
return TCL_ERROR;
}
 
theFindCurvatures = new CurvaturesBySearchAlgorithm(numberOfCurvatures,theFindDesignPoint);
}
else {
cerr << "WARNING unrecognized type of FindCurvatures \n";
return TCL_ERROR;
}
 
if (theSensitivityEvaluator == 0) {
cerr << "WARNING could not create theFindCurvatures \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addFindDesignPoint(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
 
 
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"SearchWithStepSizeAndStepDirection") == 0) {
 
int maxNumIter;
double e1;
double e2;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &maxNumIter) != TCL_OK) {
cerr << "WARNING invalid input: maxNumIter \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &e1) != TCL_OK) {
cerr << "WARNING invalid input: e1 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &e2) != TCL_OK) {
cerr << "WARNING invalid input: e2 \n";
return TCL_ERROR;
}
 
// Check that the necessary ingredients are present
if (theGFunEvaluator == 0 ) {
cerr << "Need theGFunEvaluator before a FindDesignPoint can be created" << endl;
return TCL_ERROR;
}
if (theSensitivityEvaluator == 0 ) {
cerr << "Need theSensitivityEvaluator before a FindDesignPoint can be created" << endl;
return TCL_ERROR;
}
if (theStepSizeRule == 0 ) {
cerr << "Need theStepSizeRule before a FindDesignPoint can be created" << endl;
return TCL_ERROR;
}
if (theSearchDirection == 0 ) {
cerr << "Need theSearchDirection before a FindDesignPoint can be created" << endl;
return TCL_ERROR;
}
if (theXuTransformation == 0 ) {
cerr << "Need theXuTransformation before a FindDesignPoint can be created" << endl;
return TCL_ERROR;
}
 
 
theFindDesignPoint = new SearchWithStepSizeAndStepDirection(
maxNumIter,
e1,
e2,
theGFunEvaluator,
theSensitivityEvaluator,
theStepSizeRule,
theSearchDirection,
theXuTransformation);
}
else {
cerr << "WARNING unrecognized type of FindDesignPoint Algorithm \n";
return TCL_ERROR;
}
 
if (theFindDesignPoint == 0) {
cerr << "WARNING could not create theFindDesignPoint \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addFORMAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
if (theFindDesignPoint == 0 ) {
cerr << "Need theFindDesignPoint before a FORMAnalysis can be created" << endl;
return TCL_ERROR;
}
 
theFORMAnalysis
= new FORMAnalysis(theReliabilityDomain, theFindDesignPoint );
 
if (theFORMAnalysis == 0) {
cerr << "WARNING could not create theFORMAnalysis \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addSORMAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
if (theFindCurvatures == 0 ) {
cerr << "Need theFindCurvatures before a SORMAnalysis can be created" << endl;
return TCL_ERROR;
}
 
theSORMAnalysis
= new SORMAnalysis(theReliabilityDomain, theFindCurvatures );
 
if (theSORMAnalysis == 0) {
cerr << "WARNING could not create theSORMAnalysis \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addSystemAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"allInSeries") == 0) {
 
theSystemAnalysis = new SystemAnalysis(theReliabilityDomain);
 
if (theSystemAnalysis == 0) {
cerr << "WARNING could not create theSystemAnalysis \n";
return TCL_ERROR;
}
}
return TCL_OK;
}
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addSimulationAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
int numberOfSimulations;
double targetCOV;
 
if (theXuTransformation == 0 ) {
cerr << "Need theXuTransformation before a SimulationAnalyis can be created" << endl;
return TCL_ERROR;
}
if (theGFunEvaluator == 0 ) {
cerr << "Need theGFunEvaluator before a SimulationAnalyis can be created" << endl;
return TCL_ERROR;
}
if (theRandomNumberGenerator == 0 ) {
cerr << "Need theRandomNumberGenerator before a SimulationAnalyis can be created" << endl;
return TCL_ERROR;
}
 
 
 
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &numberOfSimulations) != TCL_OK) {
cerr << "WARNING invalid input: numberOfSimulations \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &targetCOV) != TCL_OK) {
cerr << "WARNING invalid input: targetCOV \n";
return TCL_ERROR;
}
 
 
theSimulationAnalysis
= new SimulationAnalysis(theReliabilityDomain, theXuTransformation,
theGFunEvaluator, theRandomNumberGenerator,
argv[1], numberOfSimulations,
targetCOV);
 
if (theSimulationAnalysis == 0) {
cerr << "WARNING could not create theSimulationAnalysis \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_analyzeReliability(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
bool analysisIsPerformed = false;
bool systemAnalysisIsPerformed = false;
 
if (theFORMAnalysis != 0) {
if (theFORMAnalysis->analyze() < 0) {
cerr << "FORMAnalysis was NOT completed successfully." << endl;
}
else {
cerr << "FORMAnalysis completed successfully." << endl;
analysisIsPerformed = true;
}
}
if (theSORMAnalysis != 0) {
if (theSORMAnalysis->analyze() < 0) {
cerr << "SORMAnalysis was NOT completed successfully." << endl;
}
else {
cerr << "SORMAnalysis completed successfully." << endl;
analysisIsPerformed = true;
}
}
if (theSimulationAnalysis != 0) {
if (theSimulationAnalysis->analyze() < 0) {
cerr << "SimulationAnalysis was NOT completed successfully." << endl;
}
else {
cerr << "SimulationAnalysis completed successfully." << endl;
analysisIsPerformed = true;
}
}
if (theSystemAnalysis != 0) {
if (theSystemAnalysis->analyze() < 0) {
cerr << "SystemAnalysis was NOT completed successfully." << endl;
}
else {
cerr << "SystemAnalysis completed successfully." << endl;
analysisIsPerformed = true;
systemAnalysisIsPerformed = true;
}
}
 
 
// Open output file
ofstream outputFile( "reliabilityResults.txt", ios::out );
 
if (analysisIsPerformed) {
 
// Number of limit-state functions
int numLsf = theReliabilityDomain->getNumberOfLimitStateFunctions();
 
// PRINT SUMMARY OF RESULTS
outputFile << "#######################################################################" << endl;
outputFile << "# SUMMARY OF RESULTS #" << endl;
outputFile << "# Reliability Probability #" << endl;
outputFile << "# Index Beta of Failure #" << endl;
outputFile << "# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #" << endl;
 
// Loop over number of limit-state functions
int lsf;
for (lsf=1; lsf<=numLsf; lsf++ ) {
 
// Get limit-state function pointer
LimitStateFunction *theLimitStateFunction =
theReliabilityDomain->getLimitStateFunctionPtr(lsf);
 
// Print results for this limit-state function
theLimitStateFunction->printSummaryOfResults(outputFile);
}
outputFile << "# Explanations: #" << endl;
outputFile << "# SORM(1): Curvatures found by search algorithm. #" << endl;
outputFile << "# SORM(2): Curvatures found by point-fitting. #" << endl;
outputFile << "# SORM(3): Curvatures found by curvature-fitting. #" << endl;
outputFile << "# #" << endl;
outputFile << "#######################################################################" << endl << endl << endl;
 
// PRINT ECHO OF INPUT
outputFile << "#######################################################################" << endl;
outputFile << "# SUMMARY OF INPUT #" << endl;
outputFile << "# (void in present version...) #" << endl;
outputFile << "# #" << endl;
outputFile << "#######################################################################" << endl << endl << endl;
 
// PRINT COMPLETE RESULTS
// Loop over number of limit-state functions
for (lsf=1; lsf<=numLsf; lsf++ ) {
 
// Get limit-state function pointer
LimitStateFunction *theLimitStateFunction =
theReliabilityDomain->getLimitStateFunctionPtr(lsf);
 
// Print results for this limit-state function
theLimitStateFunction->printResults(outputFile);
}
 
// PRINT SYSTEM RESULTS
if (systemAnalysisIsPerformed) {
 
double lowerBound = theSystemAnalysis->getLowerBound();
double upperBound = theSystemAnalysis->getUpperBound();
outputFile << "#######################################################################" << endl;
outputFile << "# #" << endl;
outputFile << "# SYSTEM ANALYSIS RESULTS #" << endl;
outputFile << "# #" << endl;
outputFile << "# Lower probability bound: ........................... "
<<setiosflags(ios::left)<<setprecision(5)<<setw(12)<<lowerBound
<< " #" << endl;
outputFile << "# Upper probability bound: ........................... "
<<setiosflags(ios::left)<<setprecision(5)<<setw(12)<<upperBound
<< " #" << endl;
outputFile << "# #" << endl;
outputFile << "#######################################################################" << endl << endl << endl;
 
 
 
 
 
 
 
 
 
}
 
return TCL_OK;
}
else {
outputFile << "#######################################################################" << endl;
outputFile << "# #" << endl;
outputFile << "# NO ANALYSIS WAS PERFORMED #" << endl;
outputFile << "# #" << endl;
outputFile << "#######################################################################" << endl << endl << endl;
return TCL_ERROR;
}
}
 
 
 
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.4 $
// $Date: 2001-06-14 08:06:05 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/tcl/TclReliabilityBuilder.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <stdlib.h>
#include <string.h>
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
 
#include <Matrix.h>
#include <Vector.h>
#include <ID.h>
#include <ArrayOfTaggedObjects.h>
 
#include <Domain.h>
 
#include <ReliabilityDomain.h>
#include <RandomVariable.h>
#include <CorrelationCoefficient.h>
#include <LimitStateFunction.h>
#include <RandomVariablePositioner.h>
#include <NormalRV.h>
#include <LognormalRV.h>
#include <GammaRV.h>
#include <ShiftedExponentialRV.h>
#include <ShiftedRayleighRV.h>
#include <ExponentialRV.h>
#include <RayleighRV.h>
#include <UniformRV.h>
#include <BetaRV.h>
#include <Type1LargestValueRV.h>
#include <Type1SmallestValueRV.h>
#include <Type2LargestValueRV.h>
#include <Type3SmallestValueRV.h>
#include <ChiSquareRV.h>
#include <GumbelRV.h>
#include <WeibullRV.h>
#include <LaplaceRV.h>
#include <ParetoRV.h>
#include <GFunEvaluator.h>
#include <SensitivityEvaluator.h>
#include <StepSizeRule.h>
#include <SearchDirection.h>
#include <XuTransformation.h>
#include <NatafXuTransformation.h>
#include <FindDesignPoint.h>
#include <ReliabilityAnalysis.h>
#include <HLRFSearchDirection.h>
#include <ArmijoRule.h>
#include <FixedStepSizeRule.h>
#include <OpenSeesGFunEvaluator.h>
#include <OpenSeesSensitivityEvaluator.h>
#include <BasicGFunEvaluator.h>
#include <SensitivityByFiniteDifference.h>
#include <SensitivityByFiniteDifference.h>
#include <SearchWithStepSizeAndStepDirection.h>
#include <FORMAnalysis.h>
#include <SimulationAnalysis.h>
#include <RandomNumberGenerator.h>
#include <CStdLibRandGenerator.h>
#include <FindCurvatures.h>
#include <FirstPrincipalCurvature.h>
#include <CurvaturesBySearchAlgorithm.h>
#include <SORMAnalysis.h>
#include <SystemAnalysis.h>
 
 
#include <TclReliabilityBuilder.h>
 
//
// SOME STATIC POINTERS USED IN THE FUNCTIONS INVOKED BY THE INTERPRETER
//
static ReliabilityDomain *theReliabilityDomain = 0;
static Domain *theStructuralDomain = 0;
 
static GFunEvaluator *theGFunEvaluator = 0;
static SensitivityEvaluator *theSensitivityEvaluator = 0;
static StepSizeRule *theStepSizeRule = 0;
static SearchDirection *theSearchDirection = 0;
static XuTransformation *theXuTransformation = 0;
static RandomNumberGenerator *theRandomNumberGenerator = 0;
static FindDesignPoint *theFindDesignPoint = 0;
static FindCurvatures *theFindCurvatures = 0;
static ReliabilityAnalysis *theFORMAnalysis = 0;
static ReliabilityAnalysis *theSORMAnalysis = 0;
static ReliabilityAnalysis *theSimulationAnalysis = 0;
static SystemAnalysis *theSystemAnalysis = 0;
 
//
// THE PROTOTYPES OF THE FUNCTIONS INVOKED BY THE INTERPRETER
//
int TclReliabilityModelBuilder_addRandomVariable(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addCorrelate(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addLimitState(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addRandomVariablePositioner(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addXuTransformation(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addRandomNumberGenerator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addSearchDirection(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addStepSizeRule(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addgFunEvaluator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addSensitivityEvaluator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addFindDesignPoint(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addFindCurvatures(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addFORMAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addSORMAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addSystemAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_addSimulationAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
int TclReliabilityModelBuilder_analyzeReliability(ClientData clientData, Tcl_Interp *interp, int argc, char **argv);
 
 
 
//
// CLASS CONSTRUCTOR & DESTRUCTOR
//
 
// constructor: the constructor will add certain commands to the interpreter
TclReliabilityBuilder::TclReliabilityBuilder(Domain &passedDomain, Tcl_Interp *interp)
{
 
// call Tcl_CreateCommand for class specific commands
Tcl_CreateCommand(interp, "randomVariable", TclReliabilityModelBuilder_addRandomVariable,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "correlate", TclReliabilityModelBuilder_addCorrelate,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "limitState", TclReliabilityModelBuilder_addLimitState,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "randomVariablePositioner",
TclReliabilityModelBuilder_addRandomVariablePositioner,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "findDesignPoint", TclReliabilityModelBuilder_addFindDesignPoint,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "gFunEvaluator", TclReliabilityModelBuilder_addgFunEvaluator,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "sensitivityEvaluator",
TclReliabilityModelBuilder_addSensitivityEvaluator,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "stepSizeRule",
TclReliabilityModelBuilder_addStepSizeRule,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "searchDirection", TclReliabilityModelBuilder_addSearchDirection,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "xuTransformation", TclReliabilityModelBuilder_addXuTransformation,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "findCurvatures", TclReliabilityModelBuilder_addFindCurvatures,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "randomNumberGenerator",
TclReliabilityModelBuilder_addRandomNumberGenerator,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "addFORMAnalysis",TclReliabilityModelBuilder_addFORMAnalysis,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "addSORMAnalysis",TclReliabilityModelBuilder_addSORMAnalysis,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "addSystemAnalysis",TclReliabilityModelBuilder_addSystemAnalysis,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "addSimulationAnalysis",
TclReliabilityModelBuilder_addSimulationAnalysis,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "analyzeReliability",
TclReliabilityModelBuilder_analyzeReliability,
(ClientData)NULL, NULL);
 
 
// set the static pointers in this file
theStructuralDomain = &passedDomain;
theReliabilityDomain = new ReliabilityDomain();
 
// ResultsContainer *theResultsContainer = new ResultsContainer();
// theReliabilityDomain->addResultsContainer(theResultsContainer);
 
}
 
TclReliabilityBuilder::~TclReliabilityBuilder()
{
cerr << "Terje needs to write code: TclReliabilityBuilder::~TclReliabilityBuilder()\n";
}
 
 
//
// CLASS METHODS
//
 
/*
int
TclReliabilityBuilder::buildFE_Model(void)
{
// does nothing
return 0;
}
*/
 
ReliabilityDomain *
TclReliabilityBuilder::getReliabilityDomain()
{
return theReliabilityDomain;
}
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addRandomVariable(ClientData clientData,Tcl_Interp *interp,int argc,char **argv)
{
RandomVariable *theRandomVariable = 0;
int tag;
double mean;
double stdv;
double startPt;
double parameter1;
double parameter2;
double parameter3;
double parameter4;
int numberOfArguments = argc;
 
if (numberOfArguments==5) { // (Use mean/stdv WITHOUT startPt)
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &mean) != TCL_OK) {
cerr << "WARNING invalid input: mean \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &stdv) != TCL_OK) {
cerr << "WARNING invalid input: stdv \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"normal") == 0) {
theRandomVariable = new NormalRV(tag, mean, stdv);
}
else if (strcmp(argv[1],"lognormal") == 0) {
if (mean < 0.0 || stdv < 0.0) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LognormalRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"gamma") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GammaRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"shiftedExponential") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedExponentialRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"shiftedRayleigh") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedRayleighRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"exponential") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ExponentialRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"rayleigh") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new RayleighRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"uniform") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new UniformRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"beta") == 0) {
cerr << "WARNING: 'Beta' type random variable: use parameters to create!\n";
}
else if (strcmp(argv[1],"type1LargestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1LargestValueRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"type1SmallestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1SmallestValueRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"type2LargestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type2LargestValueRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"type3SmallestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type3SmallestValueRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"chiSquare") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ChiSquareRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"gumbel") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GumbelRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"weibull") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new WeibullRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"laplace") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LaplaceRV(tag, mean, stdv);
}
}
else if (strcmp(argv[1],"pareto") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ParetoRV(tag, mean, stdv);
}
}
else {
cerr << "WARNING unrecognized type of random variable \n";
cerr << "random variable: " << tag << endl;
}
 
if (theRandomVariable == 0) {
cerr << "WARNING could not create random variable" << tag << endl;
return TCL_ERROR;
}
}
 
if (numberOfArguments==6) { // (Use mean/stdv AND startPt)
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &mean) != TCL_OK) {
cerr << "WARNING invalid input: mean \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &stdv) != TCL_OK) {
cerr << "WARNING invalid input: stdv \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[5], &startPt) != TCL_OK) {
cerr << "WARNING invalid input: startPt \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"normal") == 0) {
theRandomVariable = new NormalRV(tag, mean, stdv, startPt);
}
else if (strcmp(argv[1],"lognormal") == 0) {
if (mean < 0.0 || stdv < 0.0) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LognormalRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"gamma") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GammaRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"shiftedExponential") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedExponentialRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"shiftedRayleigh") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedRayleighRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"exponential") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ExponentialRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"rayleigh") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new RayleighRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"uniform") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new UniformRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"beta") == 0) {
cerr << "WARNING: 'Beta' type random variable: use parameters to create!\n";
}
else if (strcmp(argv[1],"type1LargestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1LargestValueRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"type1SmallestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1SmallestValueRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"type2LargestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type2LargestValueRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"type3SmallestValue") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type3SmallestValueRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"chiSquare") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ChiSquareRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"gumbel") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GumbelRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"weibull") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new WeibullRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"laplace") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LaplaceRV(tag, mean, stdv, startPt);
}
}
else if (strcmp(argv[1],"pareto") == 0) {
if ( stdv < 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ParetoRV(tag, mean, stdv, startPt);
}
}
else {
cerr << "WARNING unrecognized type of random variable \n";
cerr << "random variable: " << tag << endl;
}
 
if (theRandomVariable == 0) {
cerr << "WARNING could not create random variable" << tag << endl;
return TCL_ERROR;
}
}
 
if (numberOfArguments==7) { // (Use parameters WITHOUT startPt)
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &parameter1) != TCL_OK) {
cerr << "WARNING invalid input: parameter1 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &parameter2) != TCL_OK) {
cerr << "WARNING invalid input: parameter2 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[5], &parameter3) != TCL_OK) {
cerr << "WARNING invalid input: parameter3 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[6], &parameter4) != TCL_OK) {
cerr << "WARNING invalid input: parameter4 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"normal") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new NormalRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"lognormal") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LognormalRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"gamma") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GammaRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"shiftedExponential") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedExponentialRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"shiftedRayleigh") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedRayleighRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"exponential") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ExponentialRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"rayleigh") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new RayleighRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"uniform") == 0) {
if ( parameter1 >= parameter2 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new UniformRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"beta") == 0) {
if ( parameter1 >= parameter2 || parameter3 <= 0.0 || parameter4 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new BetaRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"type1LargestValue") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1LargestValueRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"type1SmallestValue") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1SmallestValueRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"type2LargestValue") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type2LargestValueRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"type3SmallestValue") == 0) {
if ( parameter2 <= 0.0 || parameter3 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type3SmallestValueRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"chiSquare") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ChiSquareRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"gumbel") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GumbelRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"weibull") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new WeibullRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"laplace") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LaplaceRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else if (strcmp(argv[1],"pareto") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ParetoRV(tag, parameter1, parameter2, parameter3, parameter4);
}
}
else {
cerr << "WARNING unrecognized type of random variable \n";
cerr << "random variable: " << tag << endl;
}
 
if (theRandomVariable == 0) {
cerr << "WARNING could not create random variable" << tag << endl;
return TCL_ERROR;
}
}
 
 
if (numberOfArguments==8) { // (Use parameters AND startPt)
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &parameter1) != TCL_OK) {
cerr << "WARNING invalid input: parameter1 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &parameter2) != TCL_OK) {
cerr << "WARNING invalid input: parameter2 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[5], &parameter3) != TCL_OK) {
cerr << "WARNING invalid input: parameter3 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[6], &parameter4) != TCL_OK) {
cerr << "WARNING invalid input: parameter4 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[7], &startPt) != TCL_OK) {
cerr << "WARNING invalid input: startPt \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"normal") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new NormalRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"lognormal") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LognormalRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"gamma") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GammaRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"shiftedExponential") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedExponentialRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"shiftedRayleigh") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ShiftedRayleighRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"exponential") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ExponentialRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"rayleigh") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new RayleighRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"uniform") == 0) {
if ( parameter1 >= parameter2 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new UniformRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"beta") == 0) {
if ( parameter1 >= parameter2 || parameter3 <= 0.0 || parameter4 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new BetaRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"type1LargestValue") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1LargestValueRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"type1SmallestValue") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type1SmallestValueRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"type2LargestValue") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type2LargestValueRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"type3SmallestValue") == 0) {
if ( parameter2 <= 0.0 || parameter3 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new Type3SmallestValueRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"chiSquare") == 0) {
if ( parameter1 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ChiSquareRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"gumbel") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new GumbelRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"weibull") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new WeibullRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"laplace") == 0) {
if ( parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new LaplaceRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else if (strcmp(argv[1],"pareto") == 0) {
if ( parameter1 <= 0.0 || parameter2 <= 0.0 ) {
cerr << "Invalid input parameters to random variable" << tag << endl;
}
else {
theRandomVariable = new ParetoRV(tag, parameter1, parameter2, parameter3, parameter4, startPt);
}
}
else {
cerr << "WARNING unrecognized type of random variable \n";
cerr << "random variable: " << tag << endl;
}
 
if (theRandomVariable == 0) {
cerr << "WARNING could not create random variable" << tag << endl;
return TCL_ERROR;
}
}
 
 
// ADD THE OBJECT TO THE DOMAIN
if (theReliabilityDomain->addRandomVariable(theRandomVariable) == false) {
cerr << "WARNING failed to add random variable to the domain (wrong number of arguments?)\n";
cerr << "random variable: " << tag << endl;
delete theRandomVariable; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
}
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addCorrelate(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
CorrelationCoefficient *theCorrelationCoefficient = 0;
int tag;
int rv1;
int rv2;
double correlationValue;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[1], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &rv1) != TCL_OK) {
cerr << "WARNING invalid input: rv1 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[3], &rv2) != TCL_OK) {
cerr << "WARNING invalid input: rv2 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &correlationValue) != TCL_OK) {
cerr << "WARNING invalid input: correlationValue \n";
return TCL_ERROR;
}
 
// CREATE THE OBJECT
theCorrelationCoefficient = new CorrelationCoefficient(tag, rv1, rv2, correlationValue);
 
if (theCorrelationCoefficient == 0) {
cerr << "WARNING ran out of memory creating correlation coefficient \n";
cerr << "correlation coefficient: " << tag << endl;
return TCL_ERROR;
}
 
// ADD THE OBJECT TO THE DOMAIN
if (theReliabilityDomain->addCorrelationCoefficient(theCorrelationCoefficient) == false) {
cerr << "WARNING failed to add correlation coefficient to the domain\n";
cerr << "correlation coefficient: " << tag << endl;
delete theCorrelationCoefficient; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addLimitState(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
LimitStateFunction *theLimitStateFunction = 0;
int tag;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[1], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
// CREATE THE OBJECT (passing on argv[2])
theLimitStateFunction = new LimitStateFunction(tag, argv[2]);
if (theLimitStateFunction == 0) {
cerr << "WARNING ran out of memory creating limit-state function \n";
cerr << "limit-state function: " << tag << endl;
return TCL_ERROR;
}
 
// ADD THE OBJECT TO THE DOMAIN
if (theReliabilityDomain->addLimitStateFunction(theLimitStateFunction) == false) {
cerr << "WARNING failed to add limit-state function to the domain\n";
cerr << "limit-state function: " << tag << endl;
delete theLimitStateFunction; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
 
 
 
 
/*
 
LimitStateFunction *theLimitStateFunction = 0;
int tag;
int node;
int dof;
double displacementLimit;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[3], &node) != TCL_OK) {
cerr << "WARNING invalid input: node \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[4], &dof) != TCL_OK) {
cerr << "WARNING invalid input: dof \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[5], &displacementLimit) != TCL_OK) {
cerr << "WARNING invalid input: displacementLimit \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"disp") == 0) {
theLimitStateFunction = new LimitStateFunction(tag, node, dof, displacementLimit);
}
else {
cerr << "WARNING unrecognized type of limit-state function \n";
cerr << "limit-state function: " << tag << endl;
}
 
if (theLimitStateFunction == 0) {
cerr << "WARNING ran out of memory creating limit-state function \n";
cerr << "limit-state function: " << tag << endl;
return TCL_ERROR;
}
 
// ADD THE OBJECT TO THE DOMAIN
if (theReliabilityDomain->addLimitStateFunction(theLimitStateFunction) == false) {
cerr << "WARNING failed to add limit-state function to the domain\n";
cerr << "limit-state function: " << tag << endl;
delete theLimitStateFunction; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
*/
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addRandomVariablePositioner(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
RandomVariablePositioner *theRandomVariablePositioner = 0;
int tag;
int rvNumber;
int tagOfObject;
DomainComponent *theObject;
 
 
// READ THE TAG NUMBER
if (Tcl_GetInt(interp, argv[1], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// READ THE RANDOM VARIABLE NUMBER
if (Tcl_GetInt(interp, argv[2], &rvNumber) != TCL_OK) {
cerr << "WARNING invalid input: rvNumber \n";
return TCL_ERROR;
}
 
// IF UNCERTAIN *ELEMENT* PROPERTY
if (strcmp(argv[3],"element") == 0) {
 
if (Tcl_GetInt(interp, argv[4], &tagOfObject) != TCL_OK) {
cerr << "WARNING invalid input: tagOfObject \n";
return TCL_ERROR;
}
 
theObject = (DomainComponent *)theStructuralDomain->getElement(tagOfObject);
 
char *description[2];
description[0] = argv[5];
description[1] = argv[6];
 
theRandomVariablePositioner = new RandomVariablePositioner(tag,rvNumber,theObject,description,0);
}
 
 
// IF UNCERTAIN *LOAD*
else if (strcmp(argv[3],"loadPattern") == 0) {
 
if (Tcl_GetInt(interp, argv[4], &tagOfObject) != TCL_OK) {
cerr << "WARNING invalid input: tagOfObject \n";
return TCL_ERROR;
}
theObject = (DomainComponent *)theStructuralDomain->getLoadPattern(tagOfObject);
 
char *description[3];
description[0] = argv[5];
description[1] = argv[6];
description[2] = argv[7];
 
theRandomVariablePositioner = new RandomVariablePositioner(tag,rvNumber,theObject,description,0);
}
 
 
// ADD THE RANDOMVARIABLEPOSITIONER TO THE DOMAIN
if (theReliabilityDomain->addRandomVariablePositioner(theRandomVariablePositioner) == false) {
cerr << "WARNING failed to add random variable identificator to the domain\n";
cerr << "randomvariableID: " << tag << endl;
delete theRandomVariablePositioner; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
 
 
 
 
 
 
 
/*
// THE OLD VERSION OF THIS FUNCTION:
 
RandomVariablePositioner *theRandomVariablePositioner = 0;
int tag;
int rvNumber;
int typeOfObject;
int tagOfObject;
int typeOfParameterInObject;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[1], &tag) != TCL_OK) {
cerr << "WARNING invalid input: tag \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &rvNumber) != TCL_OK) {
cerr << "WARNING invalid input: rvNumber \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[3], &typeOfObject) != TCL_OK) {
cerr << "WARNING invalid input: typeOfObject \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[4], &tagOfObject) != TCL_OK) {
cerr << "WARNING invalid input: tagOfObject \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[5], &typeOfParameterInObject) != TCL_OK) {
cerr << "WARNING invalid input: typeOfParameterInObject \n";
return TCL_ERROR;
}
 
 
// CREATE THE OBJECT
theRandomVariablePositioner = new RandomVariablePositioner(tag, rvNumber, typeOfObject, tagOfObject, typeOfParameterInObject);
 
if (theRandomVariablePositioner == 0) {
cerr << "WARNING ran out of memory creating random variable identificator \n";
cerr << "randomVariableID: " << tag << endl;
return TCL_ERROR;
}
 
// ADD THE OBJECT TO THE DOMAIN
if (theReliabilityDomain->addRandomVariablePositioner(theRandomVariablePositioner) == false) {
cerr << "WARNING failed to add random variable identificator to the domain\n";
cerr << "randomvariableID: " << tag << endl;
delete theRandomVariablePositioner; // otherwise memory leak
return TCL_ERROR;
}
 
return TCL_OK;
*/
}
 
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addRandomNumberGenerator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"CStdLibRandGenerator") == 0) {
theRandomNumberGenerator = new CStdLibRandGenerator();
}
else {
cerr << "WARNING unrecognized type of RandomNumberGenerator \n";
return TCL_ERROR;
}
 
if (theRandomNumberGenerator == 0) {
cerr << "WARNING could not create theRandomNumberGenerator \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addXuTransformation(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"NatafXuTransformation") == 0) {
theXuTransformation = new NatafXuTransformation(theReliabilityDomain);
}
else {
cerr << "WARNING unrecognized type of XuTransformation \n";
return TCL_ERROR;
}
 
if (theXuTransformation == 0) {
cerr << "WARNING could not create theXuTransformation \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addSearchDirection(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"HLRFSearchDirection") == 0) {
theSearchDirection = new HLRFSearchDirection();
}
else {
cerr << "WARNING unrecognized type of SearchDirection \n";
return TCL_ERROR;
}
 
if (theSearchDirection == 0) {
cerr << "WARNING could not create theSearchDirection \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addStepSizeRule(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"ArmijoRule") == 0) {
// Check that the necessary ingredients are present
if (theGFunEvaluator == 0 ) {
cerr << "Need theGFunEvaluator before a ArmijoRule can be created" << endl;
return TCL_ERROR;
}
if (theGFunEvaluator == 0 ) {
cerr << "Need theXuTransformation before a ArmijoRule can be created" << endl;
return TCL_ERROR;
}
 
theStepSizeRule = new ArmijoRule(theGFunEvaluator,theXuTransformation);
}
else if (strcmp(argv[1],"FixedStepSizeRule") == 0) {
 
double stepSize;
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[2], &stepSize) != TCL_OK) {
cerr << "WARNING invalid input: stepSize \n";
return TCL_ERROR;
}
 
theStepSizeRule = new FixedStepSizeRule(stepSize);
}
else {
cerr << "WARNING unrecognized type of StepSizeRule \n";
return TCL_ERROR;
}
 
if (theStepSizeRule == 0) {
cerr << "WARNING could not create theStepSizeRule \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addgFunEvaluator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"OpenSeesGFunEvaluator") == 0) {
 
int numIter;
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &numIter) != TCL_OK) {
cerr << "WARNING invalid input: numIter \n";
return TCL_ERROR;
}
 
theGFunEvaluator = new OpenSeesGFunEvaluator(numIter, interp, theReliabilityDomain);
}
else if (strcmp(argv[1],"BasicGFunEvaluator") == 0) {
theGFunEvaluator = new BasicGFunEvaluator(interp, theReliabilityDomain);
}
else {
cerr << "WARNING unrecognized type of GFunEvaluator \n";
return TCL_ERROR;
}
if (theGFunEvaluator == 0) {
cerr << "WARNING could not create the theGFunEvaluator \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addSensitivityEvaluator(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"SensitivityByFiniteDifference") == 0) {
 
// Check that the necessary ingredients are present
if (theGFunEvaluator == 0 ) {
cerr << "Need theGFunEvaluator before a SensitivityByFiniteDifference can be created" << endl;
return TCL_ERROR;
}
 
theSensitivityEvaluator = new SensitivityByFiniteDifference(theGFunEvaluator, theReliabilityDomain);
}
else if (strcmp(argv[1],"OpenSeesSensitivityEvaluator") == 0) {
 
theSensitivityEvaluator = new OpenSeesSensitivityEvaluator(interp, theReliabilityDomain);
}
else {
cerr << "WARNING unrecognized type of SensitivityEvaluator \n";
return TCL_ERROR;
}
 
if (theSensitivityEvaluator == 0) {
cerr << "WARNING could not create theSensitivityEvaluator \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addFindCurvatures(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"onlyFirstPrincipal") == 0) {
 
theFindCurvatures = new FirstPrincipalCurvature();
}
else if (strcmp(argv[1],"bySearchAlgorithm") == 0) {
 
// Check that the necessary ingredients are present
if (theFindDesignPoint == 0 ) {
cerr << "Need theFindDesignPoint before a CurvaturesBySearchAlgorithm can be created" << endl;
return TCL_ERROR;
}
 
int numberOfCurvatures;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &numberOfCurvatures) != TCL_OK) {
cerr << "WARNING invalid input: numberOfCurvatures \n";
return TCL_ERROR;
}
 
theFindCurvatures = new CurvaturesBySearchAlgorithm(numberOfCurvatures,theFindDesignPoint);
}
else {
cerr << "WARNING unrecognized type of FindCurvatures \n";
return TCL_ERROR;
}
 
if (theSensitivityEvaluator == 0) {
cerr << "WARNING could not create theFindCurvatures \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addFindDesignPoint(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
 
 
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"SearchWithStepSizeAndStepDirection") == 0) {
 
int maxNumIter;
double e1;
double e2;
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &maxNumIter) != TCL_OK) {
cerr << "WARNING invalid input: maxNumIter \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &e1) != TCL_OK) {
cerr << "WARNING invalid input: e1 \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[4], &e2) != TCL_OK) {
cerr << "WARNING invalid input: e2 \n";
return TCL_ERROR;
}
 
// Check that the necessary ingredients are present
if (theGFunEvaluator == 0 ) {
cerr << "Need theGFunEvaluator before a FindDesignPoint can be created" << endl;
return TCL_ERROR;
}
if (theSensitivityEvaluator == 0 ) {
cerr << "Need theSensitivityEvaluator before a FindDesignPoint can be created" << endl;
return TCL_ERROR;
}
if (theStepSizeRule == 0 ) {
cerr << "Need theStepSizeRule before a FindDesignPoint can be created" << endl;
return TCL_ERROR;
}
if (theSearchDirection == 0 ) {
cerr << "Need theSearchDirection before a FindDesignPoint can be created" << endl;
return TCL_ERROR;
}
if (theXuTransformation == 0 ) {
cerr << "Need theXuTransformation before a FindDesignPoint can be created" << endl;
return TCL_ERROR;
}
 
 
theFindDesignPoint = new SearchWithStepSizeAndStepDirection(
maxNumIter,
e1,
e2,
theGFunEvaluator,
theSensitivityEvaluator,
theStepSizeRule,
theSearchDirection,
theXuTransformation);
}
else {
cerr << "WARNING unrecognized type of FindDesignPoint Algorithm \n";
return TCL_ERROR;
}
 
if (theFindDesignPoint == 0) {
cerr << "WARNING could not create theFindDesignPoint \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addFORMAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
if (theFindDesignPoint == 0 ) {
cerr << "Need theFindDesignPoint before a FORMAnalysis can be created" << endl;
return TCL_ERROR;
}
 
theFORMAnalysis
= new FORMAnalysis(theReliabilityDomain, theFindDesignPoint );
 
if (theFORMAnalysis == 0) {
cerr << "WARNING could not create theFORMAnalysis \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addSORMAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
if (theFindCurvatures == 0 ) {
cerr << "Need theFindCurvatures before a SORMAnalysis can be created" << endl;
return TCL_ERROR;
}
 
theSORMAnalysis
= new SORMAnalysis(theReliabilityDomain, theFindCurvatures );
 
if (theSORMAnalysis == 0) {
cerr << "WARNING could not create theSORMAnalysis \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addSystemAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
 
// GET INPUT PARAMETER (string) AND CREATE THE OBJECT
if (strcmp(argv[1],"allInSeries") == 0) {
 
theSystemAnalysis = new SystemAnalysis(theReliabilityDomain);
 
if (theSystemAnalysis == 0) {
cerr << "WARNING could not create theSystemAnalysis \n";
return TCL_ERROR;
}
}
return TCL_OK;
}
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_addSimulationAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
int numberOfSimulations;
double targetCOV;
 
if (theXuTransformation == 0 ) {
cerr << "Need theXuTransformation before a SimulationAnalyis can be created" << endl;
return TCL_ERROR;
}
if (theGFunEvaluator == 0 ) {
cerr << "Need theGFunEvaluator before a SimulationAnalyis can be created" << endl;
return TCL_ERROR;
}
if (theRandomNumberGenerator == 0 ) {
cerr << "Need theRandomNumberGenerator before a SimulationAnalyis can be created" << endl;
return TCL_ERROR;
}
 
 
 
 
// GET INPUT PARAMETER (integer)
if (Tcl_GetInt(interp, argv[2], &numberOfSimulations) != TCL_OK) {
cerr << "WARNING invalid input: numberOfSimulations \n";
return TCL_ERROR;
}
 
// GET INPUT PARAMETER (double)
if (Tcl_GetDouble(interp, argv[3], &targetCOV) != TCL_OK) {
cerr << "WARNING invalid input: targetCOV \n";
return TCL_ERROR;
}
 
 
theSimulationAnalysis
= new SimulationAnalysis(theReliabilityDomain, theXuTransformation,
theGFunEvaluator, theRandomNumberGenerator,
argv[1], numberOfSimulations,
targetCOV);
 
if (theSimulationAnalysis == 0) {
cerr << "WARNING could not create theSimulationAnalysis \n";
return TCL_ERROR;
}
return TCL_OK;
}
 
 
 
//////////////////////////////////////////////////////////////////
int
TclReliabilityModelBuilder_analyzeReliability(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
{
bool analysisIsPerformed = false;
bool systemAnalysisIsPerformed = false;
 
if (theFORMAnalysis != 0) {
if (theFORMAnalysis->analyze() < 0) {
cerr << "FORMAnalysis was NOT completed successfully." << endl;
}
else {
cerr << "FORMAnalysis completed successfully." << endl;
analysisIsPerformed = true;
}
}
if (theSORMAnalysis != 0) {
if (theSORMAnalysis->analyze() < 0) {
cerr << "SORMAnalysis was NOT completed successfully." << endl;
}
else {
cerr << "SORMAnalysis completed successfully." << endl;
analysisIsPerformed = true;
}
}
if (theSimulationAnalysis != 0) {
if (theSimulationAnalysis->analyze() < 0) {
cerr << "SimulationAnalysis was NOT completed successfully." << endl;
}
else {
cerr << "SimulationAnalysis completed successfully." << endl;
analysisIsPerformed = true;
}
}
if (theSystemAnalysis != 0) {
if (theSystemAnalysis->analyze() < 0) {
cerr << "SystemAnalysis was NOT completed successfully." << endl;
}
else {
cerr << "SystemAnalysis completed successfully." << endl;
analysisIsPerformed = true;
systemAnalysisIsPerformed = true;
}
}
 
 
// Open output file
ofstream outputFile( "reliabilityResults.txt", ios::out );
 
if (analysisIsPerformed) {
 
// Number of limit-state functions
int numLsf = theReliabilityDomain->getNumberOfLimitStateFunctions();
 
// PRINT SUMMARY OF RESULTS
outputFile << "#######################################################################" << endl;
outputFile << "# SUMMARY OF RESULTS #" << endl;
outputFile << "# Reliability Probability #" << endl;
outputFile << "# Index Beta of Failure #" << endl;
outputFile << "# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #" << endl;
 
// Loop over number of limit-state functions
int lsf;
for (lsf=1; lsf<=numLsf; lsf++ ) {
 
// Get limit-state function pointer
LimitStateFunction *theLimitStateFunction =
theReliabilityDomain->getLimitStateFunctionPtr(lsf);
 
// Print results for this limit-state function
theLimitStateFunction->printSummaryOfResults(outputFile);
}
outputFile << "# Explanations: #" << endl;
outputFile << "# SORM(1): Curvatures found by search algorithm. #" << endl;
outputFile << "# SORM(2): Curvatures found by point-fitting. #" << endl;
outputFile << "# SORM(3): Curvatures found by curvature-fitting. #" << endl;
outputFile << "# #" << endl;
outputFile << "#######################################################################" << endl << endl << endl;
 
// PRINT ECHO OF INPUT
outputFile << "#######################################################################" << endl;
outputFile << "# SUMMARY OF INPUT #" << endl;
outputFile << "# (void in present version...) #" << endl;
outputFile << "# #" << endl;
outputFile << "#######################################################################" << endl << endl << endl;
 
// PRINT COMPLETE RESULTS
// Loop over number of limit-state functions
for (lsf=1; lsf<=numLsf; lsf++ ) {
 
// Get limit-state function pointer
LimitStateFunction *theLimitStateFunction =
theReliabilityDomain->getLimitStateFunctionPtr(lsf);
 
// Print results for this limit-state function
theLimitStateFunction->printResults(outputFile);
}
 
// PRINT SYSTEM RESULTS
if (systemAnalysisIsPerformed) {
 
double lowerBound = theSystemAnalysis->getLowerBound();
double upperBound = theSystemAnalysis->getUpperBound();
outputFile << "#######################################################################" << endl;
outputFile << "# #" << endl;
outputFile << "# SYSTEM ANALYSIS RESULTS #" << endl;
outputFile << "# #" << endl;
outputFile << "# Lower probability bound: ........................... "
<<setiosflags(ios::left)<<setprecision(5)<<setw(12)<<lowerBound
<< " #" << endl;
outputFile << "# Upper probability bound: ........................... "
<<setiosflags(ios::left)<<setprecision(5)<<setw(12)<<upperBound
<< " #" << endl;
outputFile << "# #" << endl;
outputFile << "#######################################################################" << endl << endl << endl;
 
 
 
 
 
 
 
 
 
}
 
return TCL_OK;
}
else {
outputFile << "#######################################################################" << endl;
outputFile << "# #" << endl;
outputFile << "# NO ANALYSIS WAS PERFORMED #" << endl;
outputFile << "# #" << endl;
outputFile << "#######################################################################" << endl << endl << endl;
return TCL_ERROR;
}
}
 
 
 
 
/trunk/SRC/reliability/tcl/TclReliabilityBuilder.h
1,56 → 1,56
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:24 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/tcl/TclReliabilityBuilder.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:06 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/tcl/TclReliabilityBuilder.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef TclReliabilityBuilder_h
#define TclReliabilityBuilder_h
 
#include <tcl.h>
#include <tcl.h>
#include <ReliabilityDomain.h>
 
class TclReliabilityBuilder
{
public:
TclReliabilityBuilder(Domain &theDomain, Tcl_Interp *interp);
~TclReliabilityBuilder();
TclReliabilityBuilder(Domain &theDomain, Tcl_Interp *interp);
~TclReliabilityBuilder();
ReliabilityDomain *getReliabilityDomain();
 
protected:
 
private:
 
 
};
 
#endif
/trunk/SRC/reliability/analysis/curvature/FirstPrincipalCurvature.h
1,60 → 1,60
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/FirstPrincipalCurvature.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef FirstPrincipalCurvature_h
#define FirstPrincipalCurvature_h
 
#include <FindCurvatures.h>
#include <Vector.h>
#include <ReliabilityDomain.h>
 
class FirstPrincipalCurvature : public FindCurvatures
{
 
public:
FirstPrincipalCurvature();
~FirstPrincipalCurvature();
 
int computeCurvatures(ReliabilityDomain *theReliabilityDomain);
Vector getCurvatures();
 
protected:
 
private:
Vector *curvatures;
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/FirstPrincipalCurvature.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef FirstPrincipalCurvature_h
#define FirstPrincipalCurvature_h
 
#include <FindCurvatures.h>
#include <Vector.h>
#include <ReliabilityDomain.h>
 
class FirstPrincipalCurvature : public FindCurvatures
{
 
public:
FirstPrincipalCurvature();
~FirstPrincipalCurvature();
 
int computeCurvatures(ReliabilityDomain *theReliabilityDomain);
Vector getCurvatures();
 
protected:
 
private:
Vector *curvatures;
 
};
 
#endif
/trunk/SRC/reliability/analysis/curvature/CurvaturesBySearchAlgorithm.h
1,63 → 1,63
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/CurvaturesBySearchAlgorithm.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef CurvaturesBySearchAlgorithm_h
#define CurvaturesBySearchAlgorithm_h
 
#include <FindCurvatures.h>
#include <FindDesignPoint.h>
#include <Vector.h>
#include <ReliabilityDomain.h>
 
class CurvaturesBySearchAlgorithm : public FindCurvatures
{
 
public:
CurvaturesBySearchAlgorithm(int numberOfCurvatures, FindDesignPoint *theFindDesignPoint);
~CurvaturesBySearchAlgorithm();
 
int computeCurvatures(ReliabilityDomain *theReliabilityDomain);
Vector getCurvatures();
 
protected:
 
private:
Vector *curvatures;
int numberOfCurvatures;
FindDesignPoint *theFindDesignPoint;
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/CurvaturesBySearchAlgorithm.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef CurvaturesBySearchAlgorithm_h
#define CurvaturesBySearchAlgorithm_h
 
#include <FindCurvatures.h>
#include <FindDesignPoint.h>
#include <Vector.h>
#include <ReliabilityDomain.h>
 
class CurvaturesBySearchAlgorithm : public FindCurvatures
{
 
public:
CurvaturesBySearchAlgorithm(int numberOfCurvatures, FindDesignPoint *theFindDesignPoint);
~CurvaturesBySearchAlgorithm();
 
int computeCurvatures(ReliabilityDomain *theReliabilityDomain);
Vector getCurvatures();
 
protected:
 
private:
Vector *curvatures;
int numberOfCurvatures;
FindDesignPoint *theFindDesignPoint;
 
};
 
#endif
/trunk/SRC/reliability/analysis/curvature/FindCurvatures.cpp
1,46 → 1,46
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/FindCurvatures.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <FindCurvatures.h>
 
FindCurvatures::FindCurvatures()
{
}
 
FindCurvatures::~FindCurvatures()
{
}
 
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/FindCurvatures.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <FindCurvatures.h>
 
FindCurvatures::FindCurvatures()
{
}
 
FindCurvatures::~FindCurvatures()
{
}
 
 
/trunk/SRC/reliability/analysis/curvature/FindCurvatures.h
1,58 → 1,58
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/FindCurvatures.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef FindCurvatures_h
#define FindCurvatures_h
 
#include <ReliabilityDomain.h>
#include <Vector.h>
 
class FindCurvatures
{
 
public:
FindCurvatures();
virtual ~FindCurvatures();
 
virtual int computeCurvatures(ReliabilityDomain *theReliabilityDomain) =0;
virtual Vector getCurvatures() =0;
 
protected:
 
private:
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/FindCurvatures.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef FindCurvatures_h
#define FindCurvatures_h
 
#include <ReliabilityDomain.h>
#include <Vector.h>
 
class FindCurvatures
{
 
public:
FindCurvatures();
virtual ~FindCurvatures();
 
virtual int computeCurvatures(ReliabilityDomain *theReliabilityDomain) =0;
virtual Vector getCurvatures() =0;
 
protected:
 
private:
 
};
 
#endif
/trunk/SRC/reliability/analysis/curvature/FirstPrincipalCurvature.cpp
1,100 → 1,100
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/FirstPrincipalCurvature.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <FirstPrincipalCurvature.h>
#include <FindCurvatures.h>
#include <LimitStateFunction.h>
#include <Vector.h>
 
 
FirstPrincipalCurvature::FirstPrincipalCurvature()
:FindCurvatures()
{
}
 
FirstPrincipalCurvature::~FirstPrincipalCurvature()
{
}
 
 
int
FirstPrincipalCurvature::computeCurvatures(ReliabilityDomain *theReliabilityDomain)
{
 
// "Download" limit-state function from reliability domain
int lsf = theReliabilityDomain->getTagOfActiveLimitStateFunction();
LimitStateFunction *theLimitStateFunction =
theReliabilityDomain->getLimitStateFunctionPtr(lsf);
 
// Get hold of 'u' and 'alpha' at the two last steps
Vector last_u = theLimitStateFunction->designPoint_u_inStdNormalSpace;
Vector secondLast_u = theLimitStateFunction->secondLast_u;
Vector lastAlpha = theLimitStateFunction->normalizedNegativeGradientVectorAlpha;
Vector secondLastAlpha = theLimitStateFunction->secondLastAlpha;
 
// Compute curvature according to Der Kiureghian & De Stefano (1992), Eq.26:
 
// Initial computations
Vector uLastMinus_u = last_u - secondLast_u;
double signumProduct = secondLastAlpha ^ uLastMinus_u;
double alphaProduct = secondLastAlpha ^ lastAlpha;
double sumSquared = 0.0;
 
// Compute norm of the difference vector
for ( int i=0; i<last_u.Size(); i++ ) {
sumSquared += uLastMinus_u(i)*uLastMinus_u(i);
}
 
double norm_uLastMinus_u = sqrt(sumSquared);
 
// Check sign and compute curvature
if (fabs(signumProduct)==(signumProduct)) {
(*curvatures)(0) = acos(alphaProduct) / norm_uLastMinus_u;
}
else {
(*curvatures)(0) = -acos(alphaProduct) / norm_uLastMinus_u;
}
 
return 0;
}
 
 
Vector
FirstPrincipalCurvature::getCurvatures()
{
return (*curvatures);
}
 
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/FirstPrincipalCurvature.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <FirstPrincipalCurvature.h>
#include <FindCurvatures.h>
#include <LimitStateFunction.h>
#include <Vector.h>
 
 
FirstPrincipalCurvature::FirstPrincipalCurvature()
:FindCurvatures()
{
}
 
FirstPrincipalCurvature::~FirstPrincipalCurvature()
{
}
 
 
int
FirstPrincipalCurvature::computeCurvatures(ReliabilityDomain *theReliabilityDomain)
{
 
// "Download" limit-state function from reliability domain
int lsf = theReliabilityDomain->getTagOfActiveLimitStateFunction();
LimitStateFunction *theLimitStateFunction =
theReliabilityDomain->getLimitStateFunctionPtr(lsf);
 
// Get hold of 'u' and 'alpha' at the two last steps
Vector last_u = theLimitStateFunction->designPoint_u_inStdNormalSpace;
Vector secondLast_u = theLimitStateFunction->secondLast_u;
Vector lastAlpha = theLimitStateFunction->normalizedNegativeGradientVectorAlpha;
Vector secondLastAlpha = theLimitStateFunction->secondLastAlpha;
 
// Compute curvature according to Der Kiureghian & De Stefano (1992), Eq.26:
 
// Initial computations
Vector uLastMinus_u = last_u - secondLast_u;
double signumProduct = secondLastAlpha ^ uLastMinus_u;
double alphaProduct = secondLastAlpha ^ lastAlpha;
double sumSquared = 0.0;
 
// Compute norm of the difference vector
for ( int i=0; i<last_u.Size(); i++ ) {
sumSquared += uLastMinus_u(i)*uLastMinus_u(i);
}
 
double norm_uLastMinus_u = sqrt(sumSquared);
 
// Check sign and compute curvature
if (fabs(signumProduct)==(signumProduct)) {
(*curvatures)(0) = acos(alphaProduct) / norm_uLastMinus_u;
}
else {
(*curvatures)(0) = -acos(alphaProduct) / norm_uLastMinus_u;
}
 
return 0;
}
 
 
Vector
FirstPrincipalCurvature::getCurvatures()
{
return (*curvatures);
}
 
 
/trunk/SRC/reliability/analysis/curvature/CurvaturesBySearchAlgorithm.cpp
1,165 → 1,165
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/CurvaturesBySearchAlgorithm.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <CurvaturesBySearchAlgorithm.h>
#include <FindCurvatures.h>
#include <LimitStateFunction.h>
#include <FindDesignPoint.h>
#include <RandomVariable.h>
#include <Vector.h>
 
 
CurvaturesBySearchAlgorithm::CurvaturesBySearchAlgorithm(int passedNumberOfCurvatures,
FindDesignPoint *passedFindDesignPoint)
:FindCurvatures()
{
numberOfCurvatures = passedNumberOfCurvatures;
theFindDesignPoint = passedFindDesignPoint;
}
 
CurvaturesBySearchAlgorithm::~CurvaturesBySearchAlgorithm()
{
}
 
 
int
CurvaturesBySearchAlgorithm::computeCurvatures(ReliabilityDomain *theReliabilityDomain)
{
 
// Initial declarations
Vector last_u;
Vector secondLast_u;
Vector lastAlpha;
Vector secondLastAlpha;
Vector lastDirection;
Vector uLastMinus_u = last_u - secondLast_u;
double signumProduct;
double alphaProduct;
double sumSquared;
double norm_uLastMinus_u;
 
// "Download" limit-state function from reliability domain
int lsf = theReliabilityDomain->getTagOfActiveLimitStateFunction();
LimitStateFunction *theLimitStateFunction =
theReliabilityDomain->getLimitStateFunctionPtr(lsf);
 
// The design point in the original space
Vector x_star = theLimitStateFunction->designPoint_x_inOriginalSpace;
 
// Number of random variables
int nrv = x_star.Size();
 
// Declare vector to store all principal axes
Vector principalAxes( nrv * numberOfCurvatures );
 
// Start point of new searches: Perturb x^star by 10% of each standard deviation
Vector startPoint(nrv);
RandomVariable *aRandomVariable;
int numberOfRandomVariables = theReliabilityDomain->getNumberOfRandomVariables();
int i;
for (i=0; i<nrv; i++) {
aRandomVariable = theReliabilityDomain->getRandomVariablePtr(i+1);
// startPoint(i) = x_star(i) + 0.1 * aRandomVariable->getStdv();
startPoint(i) = aRandomVariable->getStartValue();
}
 
// Compute curvatures by repeated searches
for (i=0; i<numberOfCurvatures; i++) {
 
// Get hold of 'u', 'alpha' and search direction at the two last steps
last_u = theLimitStateFunction->designPoint_u_inStdNormalSpace;
secondLast_u = theLimitStateFunction->secondLast_u;
lastAlpha = theLimitStateFunction->normalizedNegativeGradientVectorAlpha;
secondLastAlpha = theLimitStateFunction->secondLastAlpha;
lastDirection = theLimitStateFunction->lastSearchDirection;
 
// Compute curvature according to Der Kiureghian & De Stefano (1992), Eq.26:
 
// Initial computations
uLastMinus_u = last_u - secondLast_u;
signumProduct = secondLastAlpha ^ uLastMinus_u;
alphaProduct = secondLastAlpha ^ lastAlpha;
sumSquared = 0.0;
 
// Compute norm of the difference vector
for ( int k=0; k<last_u.Size(); k++ ) {
sumSquared += uLastMinus_u(k)*uLastMinus_u(k);
}
norm_uLastMinus_u = sqrt(sumSquared);
 
// Check sign and compute curvature
if (fabs(signumProduct)==(signumProduct)) {
(*curvatures)(i) = acos(alphaProduct) / norm_uLastMinus_u;
}
else {
(*curvatures)(i) = -acos(alphaProduct) / norm_uLastMinus_u;
}
 
// Run a new search in the subspace orthogonal to previous principal directions
if ( i!=(numberOfCurvatures-1) ) {
 
// Store all previous principal axes in a vector
for (int j=0; j<nrv; j++ ) {
principalAxes((i*nrv)+j) = lastDirection(j);
}
 
// Do the new search
theFindDesignPoint->approachDesignPointThroughOrthogonalSubspace(
&last_u, (i+1), &principalAxes, &startPoint, theReliabilityDomain);
}
}
 
return 0;
 
 
 
/*
// Should make a check on how many iterations is used:
// should not be too few!
// Also: check on the cases in the paper!
*/
 
}
 
 
 
Vector
CurvaturesBySearchAlgorithm::getCurvatures()
{
return (*curvatures);
}
 
 
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/curvature/CurvaturesBySearchAlgorithm.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <CurvaturesBySearchAlgorithm.h>
#include <FindCurvatures.h>
#include <LimitStateFunction.h>
#include <FindDesignPoint.h>
#include <RandomVariable.h>
#include <Vector.h>
 
 
CurvaturesBySearchAlgorithm::CurvaturesBySearchAlgorithm(int passedNumberOfCurvatures,
FindDesignPoint *passedFindDesignPoint)
:FindCurvatures()
{
numberOfCurvatures = passedNumberOfCurvatures;
theFindDesignPoint = passedFindDesignPoint;
}
 
CurvaturesBySearchAlgorithm::~CurvaturesBySearchAlgorithm()
{
}
 
 
int
CurvaturesBySearchAlgorithm::computeCurvatures(ReliabilityDomain *theReliabilityDomain)
{
 
// Initial declarations
Vector last_u;
Vector secondLast_u;
Vector lastAlpha;
Vector secondLastAlpha;
Vector lastDirection;
Vector uLastMinus_u = last_u - secondLast_u;
double signumProduct;
double alphaProduct;
double sumSquared;
double norm_uLastMinus_u;
 
// "Download" limit-state function from reliability domain
int lsf = theReliabilityDomain->getTagOfActiveLimitStateFunction();
LimitStateFunction *theLimitStateFunction =
theReliabilityDomain->getLimitStateFunctionPtr(lsf);
 
// The design point in the original space
Vector x_star = theLimitStateFunction->designPoint_x_inOriginalSpace;
 
// Number of random variables
int nrv = x_star.Size();
 
// Declare vector to store all principal axes
Vector principalAxes( nrv * numberOfCurvatures );
 
// Start point of new searches: Perturb x^star by 10% of each standard deviation
Vector startPoint(nrv);
RandomVariable *aRandomVariable;
int numberOfRandomVariables = theReliabilityDomain->getNumberOfRandomVariables();
int i;
for (i=0; i<nrv; i++) {
aRandomVariable = theReliabilityDomain->getRandomVariablePtr(i+1);
// startPoint(i) = x_star(i) + 0.1 * aRandomVariable->getStdv();
startPoint(i) = aRandomVariable->getStartValue();
}
 
// Compute curvatures by repeated searches
for (i=0; i<numberOfCurvatures; i++) {
 
// Get hold of 'u', 'alpha' and search direction at the two last steps
last_u = theLimitStateFunction->designPoint_u_inStdNormalSpace;
secondLast_u = theLimitStateFunction->secondLast_u;
lastAlpha = theLimitStateFunction->normalizedNegativeGradientVectorAlpha;
secondLastAlpha = theLimitStateFunction->secondLastAlpha;
lastDirection = theLimitStateFunction->lastSearchDirection;
 
// Compute curvature according to Der Kiureghian & De Stefano (1992), Eq.26:
 
// Initial computations
uLastMinus_u = last_u - secondLast_u;
signumProduct = secondLastAlpha ^ uLastMinus_u;
alphaProduct = secondLastAlpha ^ lastAlpha;
sumSquared = 0.0;
 
// Compute norm of the difference vector
for ( int k=0; k<last_u.Size(); k++ ) {
sumSquared += uLastMinus_u(k)*uLastMinus_u(k);
}
norm_uLastMinus_u = sqrt(sumSquared);
 
// Check sign and compute curvature
if (fabs(signumProduct)==(signumProduct)) {
(*curvatures)(i) = acos(alphaProduct) / norm_uLastMinus_u;
}
else {
(*curvatures)(i) = -acos(alphaProduct) / norm_uLastMinus_u;
}
 
// Run a new search in the subspace orthogonal to previous principal directions
if ( i!=(numberOfCurvatures-1) ) {
 
// Store all previous principal axes in a vector
for (int j=0; j<nrv; j++ ) {
principalAxes((i*nrv)+j) = lastDirection(j);
}
 
// Do the new search
theFindDesignPoint->approachDesignPointThroughOrthogonalSubspace(
&last_u, (i+1), &principalAxes, &startPoint, theReliabilityDomain);
}
}
 
return 0;
 
 
 
/*
// Should make a check on how many iterations is used:
// should not be too few!
// Also: check on the cases in the paper!
*/
 
}
 
 
 
Vector
CurvaturesBySearchAlgorithm::getCurvatures()
{
return (*curvatures);
}
 
 
 
/trunk/SRC/reliability/analysis/direction/HLRFSearchDirection.cpp
1,94 → 1,94
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:17 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/direction/HLRFSearchDirection.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <HLRFSearchDirection.h>
#include <SearchDirection.h>
#include <Vector.h>
 
 
HLRFSearchDirection::HLRFSearchDirection()
:SearchDirection()
{
searchDirection = new Vector(1);
}
 
HLRFSearchDirection::~HLRFSearchDirection()
{
delete searchDirection;
}
 
 
 
 
Vector
HLRFSearchDirection::getSearchDirection()
{
return (*searchDirection);
}
 
 
 
int
HLRFSearchDirection::computeSearchDirection(
Vector u,
double gFunctionValue,
Vector gradientInStandardNormalSpace )
{
// Compute the norm of the gradient
double normOfGradient = gradientInStandardNormalSpace.Norm();
 
 
// Check that the norm is not zero
if (normOfGradient == 0.0) {
cerr << "HLRFSearchDirection::computeSearchDirection() - " << endl
<< " the norm of the gradient is zero. " << endl;
return -1;
}
 
// Compute the alpha-vector
Vector alpha = gradientInStandardNormalSpace * ( (-1) / normOfGradient );
 
 
// Compute the direction vector
double alpha_times_u = alpha ^ u ;
Vector direction = alpha * ( gFunctionValue / normOfGradient + alpha_times_u ) - u;
 
 
(*searchDirection) = direction;
 
return 0;
}
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/direction/HLRFSearchDirection.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <HLRFSearchDirection.h>
#include <SearchDirection.h>
#include <Vector.h>
 
 
HLRFSearchDirection::HLRFSearchDirection()
:SearchDirection()
{
searchDirection = new Vector(1);
}
 
HLRFSearchDirection::~HLRFSearchDirection()
{
delete searchDirection;
}
 
 
 
 
Vector
HLRFSearchDirection::getSearchDirection()
{
return (*searchDirection);
}
 
 
 
int
HLRFSearchDirection::computeSearchDirection(
Vector u,
double gFunctionValue,
Vector gradientInStandardNormalSpace )
{
// Compute the norm of the gradient
double normOfGradient = gradientInStandardNormalSpace.Norm();
 
 
// Check that the norm is not zero
if (normOfGradient == 0.0) {
cerr << "HLRFSearchDirection::computeSearchDirection() - " << endl
<< " the norm of the gradient is zero. " << endl;
return -1;
}
 
// Compute the alpha-vector
Vector alpha = gradientInStandardNormalSpace * ( (-1) / normOfGradient );
 
 
// Compute the direction vector
double alpha_times_u = alpha ^ u ;
Vector direction = alpha * ( gFunctionValue / normOfGradient + alpha_times_u ) - u;
 
 
(*searchDirection) = direction;
 
return 0;
}
 
/trunk/SRC/reliability/analysis/direction/SearchDirection.cpp
1,45 → 1,45
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:17 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/direction/SearchDirection.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <SearchDirection.h>
 
SearchDirection::SearchDirection()
{
}
 
SearchDirection::~SearchDirection()
{
}
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/direction/SearchDirection.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <SearchDirection.h>
 
SearchDirection::SearchDirection()
{
}
 
SearchDirection::~SearchDirection()
{
}
 
/trunk/SRC/reliability/analysis/direction/HLRFSearchDirection.h
1,61 → 1,61
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:17 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/direction/HLRFSearchDirection.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef HLRFSearchDirection_h
#define HLRFSearchDirection_h
 
#include <SearchDirection.h>
#include <Vector.h>
 
class HLRFSearchDirection : public SearchDirection
{
 
public:
HLRFSearchDirection();
~HLRFSearchDirection();
 
int computeSearchDirection( Vector passed_u,
double passed_gFunctionValue,
Vector passedGradientInStandardNormalSpace);
Vector getSearchDirection();
 
protected:
 
private:
Vector *searchDirection;
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/direction/HLRFSearchDirection.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef HLRFSearchDirection_h
#define HLRFSearchDirection_h
 
#include <SearchDirection.h>
#include <Vector.h>
 
class HLRFSearchDirection : public SearchDirection
{
 
public:
HLRFSearchDirection();
~HLRFSearchDirection();
 
int computeSearchDirection( Vector passed_u,
double passed_gFunctionValue,
Vector passedGradientInStandardNormalSpace);
Vector getSearchDirection();
 
protected:
 
private:
Vector *searchDirection;
 
};
 
#endif
/trunk/SRC/reliability/analysis/direction/SearchDirection.h
1,60 → 1,60
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:17 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/direction/SearchDirection.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef SearchDirection_h
#define SearchDirection_h
 
#include <Vector.h>
 
class SearchDirection
{
 
public:
SearchDirection();
virtual ~SearchDirection();
 
virtual int computeSearchDirection(
Vector passed_u,
double passed_gFunctionValue,
Vector passedGradientInStandardNormalSpace) =0;
virtual Vector getSearchDirection() =0;
 
protected:
 
private:
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/direction/SearchDirection.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef SearchDirection_h
#define SearchDirection_h
 
#include <Vector.h>
 
class SearchDirection
{
 
public:
SearchDirection();
virtual ~SearchDirection();
 
virtual int computeSearchDirection(
Vector passed_u,
double passed_gFunctionValue,
Vector passedGradientInStandardNormalSpace) =0;
virtual Vector getSearchDirection() =0;
 
protected:
 
private:
 
};
 
#endif
/trunk/SRC/reliability/analysis/analysis/ReliabilityAnalysis.h
1,54 → 1,54
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/ReliabilityAnalysis.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef ReliabilityAnalysis_h
#define ReliabilityAnalysis_h
 
class ReliabilityAnalysis
{
 
public:
ReliabilityAnalysis();
virtual ~ReliabilityAnalysis();
virtual int analyze(void) =0;
 
protected:
 
private:
};
 
#endif
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:00 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/ReliabilityAnalysis.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef ReliabilityAnalysis_h
#define ReliabilityAnalysis_h
 
class ReliabilityAnalysis
{
 
public:
ReliabilityAnalysis();
virtual ~ReliabilityAnalysis();
virtual int analyze(void) =0;
 
protected:
 
private:
};
 
#endif
 
/trunk/SRC/reliability/analysis/analysis/SORMAnalysis.cpp
1,164 → 1,164
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SORMAnalysis.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <SORMAnalysis.h>
#include <ReliabilityDomain.h>
#include <ReliabilityAnalysis.h>
#include <FindCurvatures.h>
#include <LimitStateFunction.h>
#include <NormalRV.h>
#include <math.h>
#include <Vector.h>
 
SORMAnalysis::SORMAnalysis( ReliabilityDomain *passedReliabilityDomain,
FindCurvatures *passedCurvaturesAlgorithm)
:ReliabilityAnalysis()
{
theReliabilityDomain = passedReliabilityDomain;
theCurvaturesAlgorithm = passedCurvaturesAlgorithm;
}
 
 
SORMAnalysis::~SORMAnalysis()
{
}
 
 
 
int
SORMAnalysis::analyze(void)
{
// Alert the user that the SORM analysis has started
cerr << "SORM Analysis is running ... " << endl;
 
 
// Declare variables used in this method
Vector curvatures;
int numberOfCurvatures;
double beta;
double pf1;
double psi_beta;
double product;
int i;
double pf2Breitung;
double betaBreitung;
LimitStateFunction *theLimitStateFunction;
NormalRV *aStdNormRV = 0;
aStdNormRV = new NormalRV(1,0.0,1.0,0.0);
 
 
// Check if computer ran out of memory
if (aStdNormRV==0) {
cerr << "SORMAnalysis::analyze() - out of memory while instantiating internal objects." << endl;
return -1;
}
 
 
// Number of limit-state functions
int numLsf = theReliabilityDomain->getNumberOfLimitStateFunctions();
 
 
// Loop over number of limit-state functions
for (int lsf=1; lsf<=numLsf; lsf++ ) {
 
 
// Inform the user which limit-state function is being evaluated
cerr << "Limit-state function number: " << lsf << endl;
 
 
// Set tag of "active" limit-state function
theReliabilityDomain->setTagOfActiveLimitStateFunction(lsf);
 
 
// Get the limit-state function pointer
theLimitStateFunction = 0;
lsf = theReliabilityDomain->getTagOfActiveLimitStateFunction();
theLimitStateFunction = theReliabilityDomain->getLimitStateFunctionPtr(lsf);
if (theLimitStateFunction == 0) {
cerr << "SORMAnalysis::analyze() - could not find" << endl
<< " limit-state function with tag #" << lsf << "." << endl;
return -1;
}
 
 
// Compute curvature(s)
if (theCurvaturesAlgorithm->computeCurvatures(theReliabilityDomain) < 0){
cerr << "SORMAnalysis::analyze() - failed while finding " << endl
<< " curvatures for limit-state function number " << lsf << "." << endl;
return -1;
}
 
 
// Get results
curvatures = theCurvaturesAlgorithm->getCurvatures();
numberOfCurvatures = curvatures.Size();
 
// Get FORM results from the limit-state function
beta = theLimitStateFunction->FORMReliabilityIndexBeta;
pf1 = theLimitStateFunction->FORMProbabilityOfFailure_pf1;
 
 
// Compute failure probability by "Breitung"
double denominator = aStdNormRV->getCDFvalue(-beta);
if (denominator == 0.0) {
cerr << "SORMAnalysis::analyze() - denominator zero " << endl
<< " due to too large reliability index value." << endl;
return -1;
}
psi_beta = aStdNormRV->getPDFvalue(beta)/denominator;
product = 1.0;
for (i=0; i<numberOfCurvatures; i++ ) {
product = product / sqrt(1.0+psi_beta*curvatures(i));
}
pf2Breitung = pf1 * product;
 
 
// Compute corresponding beta's
betaBreitung = -aStdNormRV->getInverseCDFvalue(pf2Breitung);
 
 
// Put results into reliability domain
theLimitStateFunction->CurvaturesFromSearchAlgorithmSORMAnalysisPerformed = true;
theLimitStateFunction->numberOfCurvatauresUsed = numberOfCurvatures;
theLimitStateFunction->SORMUsingSearchPf2Breitung = pf2Breitung;
theLimitStateFunction->SORMUsingSearchBetaBreitung = betaBreitung;
}
 
delete aStdNormRV;
 
return 0;
}
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:00 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SORMAnalysis.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <SORMAnalysis.h>
#include <ReliabilityDomain.h>
#include <ReliabilityAnalysis.h>
#include <FindCurvatures.h>
#include <LimitStateFunction.h>
#include <NormalRV.h>
#include <math.h>
#include <Vector.h>
 
SORMAnalysis::SORMAnalysis( ReliabilityDomain *passedReliabilityDomain,
FindCurvatures *passedCurvaturesAlgorithm)
:ReliabilityAnalysis()
{
theReliabilityDomain = passedReliabilityDomain;
theCurvaturesAlgorithm = passedCurvaturesAlgorithm;
}
 
 
SORMAnalysis::~SORMAnalysis()
{
}
 
 
 
int
SORMAnalysis::analyze(void)
{
// Alert the user that the SORM analysis has started
cerr << "SORM Analysis is running ... " << endl;
 
 
// Declare variables used in this method
Vector curvatures;
int numberOfCurvatures;
double beta;
double pf1;
double psi_beta;
double product;
int i;
double pf2Breitung;
double betaBreitung;
LimitStateFunction *theLimitStateFunction;
NormalRV *aStdNormRV = 0;
aStdNormRV = new NormalRV(1,0.0,1.0,0.0);
 
 
// Check if computer ran out of memory
if (aStdNormRV==0) {
cerr << "SORMAnalysis::analyze() - out of memory while instantiating internal objects." << endl;
return -1;
}
 
 
// Number of limit-state functions
int numLsf = theReliabilityDomain->getNumberOfLimitStateFunctions();
 
 
// Loop over number of limit-state functions
for (int lsf=1; lsf<=numLsf; lsf++ ) {
 
 
// Inform the user which limit-state function is being evaluated
cerr << "Limit-state function number: " << lsf << endl;
 
 
// Set tag of "active" limit-state function
theReliabilityDomain->setTagOfActiveLimitStateFunction(lsf);
 
 
// Get the limit-state function pointer
theLimitStateFunction = 0;
lsf = theReliabilityDomain->getTagOfActiveLimitStateFunction();
theLimitStateFunction = theReliabilityDomain->getLimitStateFunctionPtr(lsf);
if (theLimitStateFunction == 0) {
cerr << "SORMAnalysis::analyze() - could not find" << endl
<< " limit-state function with tag #" << lsf << "." << endl;
return -1;
}
 
 
// Compute curvature(s)
if (theCurvaturesAlgorithm->computeCurvatures(theReliabilityDomain) < 0){
cerr << "SORMAnalysis::analyze() - failed while finding " << endl
<< " curvatures for limit-state function number " << lsf << "." << endl;
return -1;
}
 
 
// Get results
curvatures = theCurvaturesAlgorithm->getCurvatures();
numberOfCurvatures = curvatures.Size();
 
// Get FORM results from the limit-state function
beta = theLimitStateFunction->FORMReliabilityIndexBeta;
pf1 = theLimitStateFunction->FORMProbabilityOfFailure_pf1;
 
 
// Compute failure probability by "Breitung"
double denominator = aStdNormRV->getCDFvalue(-beta);
if (denominator == 0.0) {
cerr << "SORMAnalysis::analyze() - denominator zero " << endl
<< " due to too large reliability index value." << endl;
return -1;
}
psi_beta = aStdNormRV->getPDFvalue(beta)/denominator;
product = 1.0;
for (i=0; i<numberOfCurvatures; i++ ) {
product = product / sqrt(1.0+psi_beta*curvatures(i));
}
pf2Breitung = pf1 * product;
 
 
// Compute corresponding beta's
betaBreitung = -aStdNormRV->getInverseCDFvalue(pf2Breitung);
 
 
// Put results into reliability domain
theLimitStateFunction->CurvaturesFromSearchAlgorithmSORMAnalysisPerformed = true;
theLimitStateFunction->numberOfCurvatauresUsed = numberOfCurvatures;
theLimitStateFunction->SORMUsingSearchPf2Breitung = pf2Breitung;
theLimitStateFunction->SORMUsingSearchBetaBreitung = betaBreitung;
}
 
delete aStdNormRV;
 
return 0;
}
 
/trunk/SRC/reliability/analysis/analysis/FORMAnalysis.cpp
1,181 → 1,181
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:15 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/FORMAnalysis.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <FORMAnalysis.h>
#include <FindDesignPoint.h>
#include <ReliabilityDomain.h>
#include <ReliabilityAnalysis.h>
#include <Vector.h>
#include <Matrix.h>
#include <MatrixOperations.h>
#include <NormalRV.h>
#include <RandomVariable.h>
#include <math.h>
 
FORMAnalysis::FORMAnalysis( ReliabilityDomain *passedReliabilityDomain,
FindDesignPoint *passedFindDesignPoint)
:ReliabilityAnalysis()
{
theReliabilityDomain = passedReliabilityDomain;
theFindDesignPoint = passedFindDesignPoint;
}
 
 
FORMAnalysis::~FORMAnalysis()
{
}
 
 
 
int
FORMAnalysis::analyze(void)
{
 
// Alert the user that the FORM analysis has started
cerr << "FORM Analysis is running ... " << endl;
 
 
// Declare variables used in this method
Vector xStar;
Vector uStar;
Vector alpha;
Vector gamma;
int i;
double Go;
Vector uSecondLast;
Vector alphaSecondLast;
Vector lastSearchDirection;
double beta;
double pf1;
int lsf;
int numRV = theReliabilityDomain->getNumberOfRandomVariables();
int numLsf = theReliabilityDomain->getNumberOfLimitStateFunctions();
Vector startValues(numRV);
RandomVariable *aRandomVariable;
LimitStateFunction *theLimitStateFunction;
NormalRV *aStdNormRV=0;
aStdNormRV = new NormalRV(1,0.0,1.0,0.0);
 
 
// Check if computer ran out of memory
if (aStdNormRV==0) {
cerr << "FORMAnalysis::analyze() - out of memory while instantiating internal objects." << endl;
return -1;
}
 
 
// Establish the user-given starting point in the original space
for ( int j=1; j<=numRV; j++ )
{
aRandomVariable = 0;
aRandomVariable = theReliabilityDomain->getRandomVariablePtr(j);
if (aRandomVariable == 0) {
cerr << "FORMAnalysis::analyze() - could not find" << endl
<< " random variable with tag #" << j << "." << endl;
return -1;
}
startValues(j-1) = aRandomVariable->getStartValue();
}
 
 
// Loop over number of limit-state functions and perform FORM analysis
for (lsf=1; lsf<=numLsf; lsf++ ) {
 
 
// Inform the user which limit-state function is being evaluated
cerr << "Limit-state function number: " << lsf << endl;
 
 
// Set tag of "active" limit-state function
theReliabilityDomain->setTagOfActiveLimitStateFunction(lsf);
 
 
// Get the limit-state function pointer
theLimitStateFunction = 0;
lsf = theReliabilityDomain->getTagOfActiveLimitStateFunction();
theLimitStateFunction = theReliabilityDomain->getLimitStateFunctionPtr(lsf);
if (theLimitStateFunction == 0) {
cerr << "FORMAnalysis::analyze() - could not find" << endl
<< " limit-state function with tag #" << lsf << "." << endl;
return -1;
}
 
 
// Find the design point
if (theFindDesignPoint->findDesignPoint(&startValues, theReliabilityDomain) < 0){
cerr << "FORMAnalysis::analyze() - failed while finding the" << endl
<< " design point for limit-state function number " << lsf << "." << endl;
return -1;
}
 
// Get results from the "find desingn point algorithm"
xStar = theFindDesignPoint->get_x();
uStar = theFindDesignPoint->get_u();
alpha = theFindDesignPoint->get_alpha();
gamma = theFindDesignPoint->get_gamma();
i = theFindDesignPoint->getNumberOfIterations();
Go = theFindDesignPoint->getFirstGFunValue();
uSecondLast = theFindDesignPoint->getSecondLast_u();
alphaSecondLast = theFindDesignPoint->getSecondLast_alpha();
lastSearchDirection = theFindDesignPoint->getLastSearchDirection();
 
 
// Postprocessing
beta = alpha ^ uStar;
pf1 = 1.0 - aStdNormRV->getCDFvalue(beta);
 
 
// Store the results
theLimitStateFunction->FORMAnalysisPerformed = true;
theLimitStateFunction->FORMReliabilityIndexBeta = beta;
theLimitStateFunction->FORMProbabilityOfFailure_pf1 = pf1;
theLimitStateFunction->designPoint_x_inOriginalSpace = xStar;
theLimitStateFunction->designPoint_u_inStdNormalSpace = uStar;
theLimitStateFunction->normalizedNegativeGradientVectorAlpha= alpha;
theLimitStateFunction->importanceVectorGamma = gamma;
theLimitStateFunction->numberOfIterationsToFindDesignPoint = i;
theLimitStateFunction->GFunValueAtStartPt = Go;
theLimitStateFunction->secondLast_u = uSecondLast;
theLimitStateFunction->secondLastAlpha = alphaSecondLast;
theLimitStateFunction->lastSearchDirection = lastSearchDirection;
 
}
 
delete aStdNormRV;
 
return 0;
}
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:00 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/FORMAnalysis.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <FORMAnalysis.h>
#include <FindDesignPoint.h>
#include <ReliabilityDomain.h>
#include <ReliabilityAnalysis.h>
#include <Vector.h>
#include <Matrix.h>
#include <MatrixOperations.h>
#include <NormalRV.h>
#include <RandomVariable.h>
#include <math.h>
 
FORMAnalysis::FORMAnalysis( ReliabilityDomain *passedReliabilityDomain,
FindDesignPoint *passedFindDesignPoint)
:ReliabilityAnalysis()
{
theReliabilityDomain = passedReliabilityDomain;
theFindDesignPoint = passedFindDesignPoint;
}
 
 
FORMAnalysis::~FORMAnalysis()
{
}
 
 
 
int
FORMAnalysis::analyze(void)
{
 
// Alert the user that the FORM analysis has started
cerr << "FORM Analysis is running ... " << endl;
 
 
// Declare variables used in this method
Vector xStar;
Vector uStar;
Vector alpha;
Vector gamma;
int i;
double Go;
Vector uSecondLast;
Vector alphaSecondLast;
Vector lastSearchDirection;
double beta;
double pf1;
int lsf;
int numRV = theReliabilityDomain->getNumberOfRandomVariables();
int numLsf = theReliabilityDomain->getNumberOfLimitStateFunctions();
Vector startValues(numRV);
RandomVariable *aRandomVariable;
LimitStateFunction *theLimitStateFunction;
NormalRV *aStdNormRV=0;
aStdNormRV = new NormalRV(1,0.0,1.0,0.0);
 
 
// Check if computer ran out of memory
if (aStdNormRV==0) {
cerr << "FORMAnalysis::analyze() - out of memory while instantiating internal objects." << endl;
return -1;
}
 
 
// Establish the user-given starting point in the original space
for ( int j=1; j<=numRV; j++ )
{
aRandomVariable = 0;
aRandomVariable = theReliabilityDomain->getRandomVariablePtr(j);
if (aRandomVariable == 0) {
cerr << "FORMAnalysis::analyze() - could not find" << endl
<< " random variable with tag #" << j << "." << endl;
return -1;
}
startValues(j-1) = aRandomVariable->getStartValue();
}
 
 
// Loop over number of limit-state functions and perform FORM analysis
for (lsf=1; lsf<=numLsf; lsf++ ) {
 
 
// Inform the user which limit-state function is being evaluated
cerr << "Limit-state function number: " << lsf << endl;
 
 
// Set tag of "active" limit-state function
theReliabilityDomain->setTagOfActiveLimitStateFunction(lsf);
 
 
// Get the limit-state function pointer
theLimitStateFunction = 0;
lsf = theReliabilityDomain->getTagOfActiveLimitStateFunction();
theLimitStateFunction = theReliabilityDomain->getLimitStateFunctionPtr(lsf);
if (theLimitStateFunction == 0) {
cerr << "FORMAnalysis::analyze() - could not find" << endl
<< " limit-state function with tag #" << lsf << "." << endl;
return -1;
}
 
 
// Find the design point
if (theFindDesignPoint->findDesignPoint(&startValues, theReliabilityDomain) < 0){
cerr << "FORMAnalysis::analyze() - failed while finding the" << endl
<< " design point for limit-state function number " << lsf << "." << endl;
return -1;
}
 
// Get results from the "find desingn point algorithm"
xStar = theFindDesignPoint->get_x();
uStar = theFindDesignPoint->get_u();
alpha = theFindDesignPoint->get_alpha();
gamma = theFindDesignPoint->get_gamma();
i = theFindDesignPoint->getNumberOfIterations();
Go = theFindDesignPoint->getFirstGFunValue();
uSecondLast = theFindDesignPoint->getSecondLast_u();
alphaSecondLast = theFindDesignPoint->getSecondLast_alpha();
lastSearchDirection = theFindDesignPoint->getLastSearchDirection();
 
 
// Postprocessing
beta = alpha ^ uStar;
pf1 = 1.0 - aStdNormRV->getCDFvalue(beta);
 
 
// Store the results
theLimitStateFunction->FORMAnalysisPerformed = true;
theLimitStateFunction->FORMReliabilityIndexBeta = beta;
theLimitStateFunction->FORMProbabilityOfFailure_pf1 = pf1;
theLimitStateFunction->designPoint_x_inOriginalSpace = xStar;
theLimitStateFunction->designPoint_u_inStdNormalSpace = uStar;
theLimitStateFunction->normalizedNegativeGradientVectorAlpha= alpha;
theLimitStateFunction->importanceVectorGamma = gamma;
theLimitStateFunction->numberOfIterationsToFindDesignPoint = i;
theLimitStateFunction->GFunValueAtStartPt = Go;
theLimitStateFunction->secondLast_u = uSecondLast;
theLimitStateFunction->secondLastAlpha = alphaSecondLast;
theLimitStateFunction->lastSearchDirection = lastSearchDirection;
 
}
 
delete aStdNormRV;
 
return 0;
}
 
/trunk/SRC/reliability/analysis/analysis/SimulationAnalysis.cpp
1,359 → 1,359
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SimulationAnalysis.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <SimulationAnalysis.h>
#include <ReliabilityDomain.h>
#include <ReliabilityAnalysis.h>
#include <LimitStateFunction.h>
#include <XuTransformation.h>
#include <NatafXuTransformation.h>
#include <GFunEvaluator.h>
#include <BasicGFunEvaluator.h>
#include <RandomNumberGenerator.h>
#include <RandomVariable.h>
#include <NormalRV.h>
#include <Vector.h>
#include <Matrix.h>
#include <MatrixOperations.h>
#include <NormalRV.h>
#include <math.h>
#include <stdlib.h>
 
 
SimulationAnalysis::SimulationAnalysis( ReliabilityDomain *passedReliabilityDomain,
XuTransformation *passedXuTransformation,
GFunEvaluator *passedGFunEvaluator,
RandomNumberGenerator *passedRandomNumberGenerator,
char *passedPointToSampleAround,
int passedNumberOfSimulations,
double passedTargetCOV)
:ReliabilityAnalysis()
{
theReliabilityDomain = passedReliabilityDomain;
theXuTransformation = passedXuTransformation;
theGFunEvaluator = passedGFunEvaluator;
theRandomNumberGenerator = passedRandomNumberGenerator;
pointToSampleAround = new char[250];
strcpy(pointToSampleAround,passedPointToSampleAround);
numberOfSimulations = passedNumberOfSimulations;
targetCOV = passedTargetCOV;
 
}
 
 
SimulationAnalysis::~SimulationAnalysis()
{
}
 
 
 
int
SimulationAnalysis::analyze(void)
{
 
// Alert the user that the simulation analysis has started
cerr << "Simulation Analysis is running ... " << endl;
 
 
// Declaration of some of the data used in the algorithm
double gFunctionValue;
int result;
int I, i, j, k;
double det_covariance;
double phi;
double h;
double q_bar, pf, cov, beta, q;
double variance_of_q_bar;
double cov_of_q_bar;
int numRV = theReliabilityDomain->getNumberOfRandomVariables();
Matrix covariance(numRV, numRV);
Matrix chol_covariance(numRV, numRV);
Matrix inv_covariance(numRV, numRV);
Vector point(numRV);
Vector startValues(numRV);
Vector x(numRV);
Vector z(numRV);
Vector u(numRV);
Vector randomArray(numRV);
RandomVariable *aRandomVariable;
LimitStateFunction *theLimitStateFunction = 0;
NormalRV *aStdNormRV = 0;
aStdNormRV = new NormalRV(1,0.0,1.0,0.0);
 
// Check if computer ran out of memory
if (aStdNormRV==0) {
cerr << "SimulationAnalysis::analyze() - out of memory while instantiating internal objects." << endl;
return -1;
}
 
// Establish covariance matrix
for (i=0; i<numRV; i++) {
for (j=0; j<numRV; j++) {
if (i==j) {
covariance(i,j) = 1.0;
}
else
covariance(i,j) = 0.0;
}
}
 
 
// Create object to do matrix operations on the covariance matrix
MatrixOperations *theMatrixOperations = 0;
theMatrixOperations = new MatrixOperations(covariance);
if (theMatrixOperations == 0) {
cerr << "SimulationAnalysis::analyze() - could not create" << endl
<< " the object to perform matrix operations." << endl;
return -1;
}
 
 
// Cholesky decomposition of covariance matrix
result = theMatrixOperations->computeLowerCholesky();
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not compute" << endl
<< " the Cholesky decomposition of the covariance matrix." << endl;
return -1;
}
chol_covariance = theMatrixOperations->getLowerCholesky();
 
 
// Inverse of covariance matrix
result = theMatrixOperations->computeInverse();
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not compute" << endl
<< " the inverse of the covariance matrix." << endl;
return -1;
}
inv_covariance = theMatrixOperations->getInverse();
 
 
// Compute the determinant, knowing that this is a diagonal matrix
result = theMatrixOperations->computeTrace();
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not compute" << endl
<< " the trace of the covariance matrix." << endl;
return -1;
}
det_covariance = theMatrixOperations->getTrace();
 
// Initializations
double sum_q;
double sum_q_squared;
 
 
// Pre-compute some factors to minimize computations inside simulation loop
double pi = 3.14159265358979;
double factor1 = 1.0 / ( pow((2.0*pi),((double)numRV/2.0)) );
double factor2 = 1.0 / ( pow((2.0*pi),((double)numRV/2.0)) * sqrt(det_covariance) );
 
 
// Number of limit-state functions
int numLsf = theReliabilityDomain->getNumberOfLimitStateFunctions();
 
 
// Loop over number of limit-state functions
for (int lsf=1; lsf<=numLsf; lsf++ ) {
 
 
// Inform the user which limit-state function is being evaluated
cerr << "Limit-state function number: " << lsf << endl;
 
 
// Set tag of "active" limit-state function
theReliabilityDomain->setTagOfActiveLimitStateFunction(lsf);
 
 
// Get the limit-state function pointer
theLimitStateFunction = 0;
lsf = theReliabilityDomain->getTagOfActiveLimitStateFunction();
theLimitStateFunction = theReliabilityDomain->getLimitStateFunctionPtr(lsf);
if (theLimitStateFunction == 0) {
cerr << "SimulationAnalysis::analyze() - could not find" << endl
<< " limit-state function with tag #" << lsf << "." << endl;
return -1;
}
 
 
// Determine the point to simulate around
if ( strcmp(pointToSampleAround, "aroundStartPoint") == 0 ) {
for ( j=1; j<=numRV; j++)
{
aRandomVariable = theReliabilityDomain->getRandomVariablePtr(j);
startValues(j-1) = aRandomVariable->getStartValue();
}
result = theXuTransformation->set_x(startValues);
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not " << endl
<< " set the x-vector for xu-transformation. " << endl;
return -1;
}
result = theXuTransformation->transform_x_to_u();
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not " << endl
<< " transform x to u. " << endl;
return -1;
}
point = theXuTransformation->get_u();
}
else if ( strcmp(pointToSampleAround, "aroundOrigin") == 0 ) {
for ( j=0; j<numRV; j++)
{
point(j) = 0.0;
}
}
else if ( strcmp(pointToSampleAround, "aroundDesignPoint") == 0 ) {
point = theLimitStateFunction->designPoint_u_inStdNormalSpace;
}
else {
cerr << "SimulationAnalysis::analyze() - " << pointToSampleAround << endl
<< " is not a valid point to sample around." << endl;
return -1;
}
 
sum_q = 0.0;
sum_q_squared = 0.0;
k = 1;
cov_of_q_bar = 999.0;
 
while( k<=numberOfSimulations && cov_of_q_bar>targetCOV ) {
 
// Create array of standard normal random numbers
result = theRandomNumberGenerator->generate_nIndependentStdNormalNumbers(numRV);
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not generate" << endl
<< " random numbers for simulation." << endl;
return -1;
}
randomArray = theRandomNumberGenerator->getGeneratedNumbers();
 
 
// Compute the point in standard normal space
u = point + chol_covariance * randomArray;
 
 
// Transform into original space
result = theXuTransformation->set_u(u);
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not " << endl
<< " set the u-vector for xu-transformation. " << endl;
return -1;
}
 
result = theXuTransformation->transform_u_to_x();
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not " << endl
<< " transform u to x. " << endl;
return -1;
}
x = theXuTransformation->get_x();
 
 
// Evaluate limit-state function
result = theGFunEvaluator->evaluate_g(x);
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not " << endl
<< " evaluate limit-state function. " << endl;
return -1;
}
gFunctionValue = theGFunEvaluator->get_g();
 
 
// Collect result of sampling
if (gFunctionValue < 0.0) {
I = 1;
}
else {
I = 0;
}
 
// Compute values of joint distributions at the u-point
phi = factor1 * exp( -0.5 * (u ^ u) );
Vector temp1 = inv_covariance ^ (u-point);
double temp2 = temp1 ^ (u-point);
h = factor2 * exp( -0.5 * temp2 );
 
 
// Update sums
q = I * phi / h;
sum_q = sum_q + q;
sum_q_squared = sum_q_squared + q*q;
 
if (sum_q > 0 && k>5 ) {
// Compute coefficient of variation (of pf)
q_bar = 1.0/(double)k * sum_q;
 
variance_of_q_bar = 1.0/(double)k *
( 1.0/(double)k * sum_q_squared - (sum_q/(double)k)*(sum_q/(double)k));
cov_of_q_bar = sqrt(variance_of_q_bar) / q_bar;
}
else {
cov_of_q_bar = 999.0;
}
 
k++;
}
// Step 'k' back a step now that we went out
k--;
 
if (sum_q > 0) {
// Compute probability of failure and reliability index
pf = q_bar;
cov = cov_of_q_bar;
beta = -aStdNormRV->getInverseCDFvalue(pf);
}
else {
pf = 0;
cov = 0;
beta = 0;
}
 
// Store results
theLimitStateFunction->SimulationAnalysisPerformed=true;
theLimitStateFunction->SimulationReliabilityIndexBeta=beta;
theLimitStateFunction->SimulationProbabilityOfFailure_pfsim=pf;
theLimitStateFunction->CoefficientOfVariationOfPfFromSimulation=cov;
theLimitStateFunction->NumberOfSimulations=k;
}
 
delete aStdNormRV;
 
return 0;
}
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:00 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SimulationAnalysis.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <SimulationAnalysis.h>
#include <ReliabilityDomain.h>
#include <ReliabilityAnalysis.h>
#include <LimitStateFunction.h>
#include <XuTransformation.h>
#include <NatafXuTransformation.h>
#include <GFunEvaluator.h>
#include <BasicGFunEvaluator.h>
#include <RandomNumberGenerator.h>
#include <RandomVariable.h>
#include <NormalRV.h>
#include <Vector.h>
#include <Matrix.h>
#include <MatrixOperations.h>
#include <NormalRV.h>
#include <math.h>
#include <stdlib.h>
 
 
SimulationAnalysis::SimulationAnalysis( ReliabilityDomain *passedReliabilityDomain,
XuTransformation *passedXuTransformation,
GFunEvaluator *passedGFunEvaluator,
RandomNumberGenerator *passedRandomNumberGenerator,
char *passedPointToSampleAround,
int passedNumberOfSimulations,
double passedTargetCOV)
:ReliabilityAnalysis()
{
theReliabilityDomain = passedReliabilityDomain;
theXuTransformation = passedXuTransformation;
theGFunEvaluator = passedGFunEvaluator;
theRandomNumberGenerator = passedRandomNumberGenerator;
pointToSampleAround = new char[250];
strcpy(pointToSampleAround,passedPointToSampleAround);
numberOfSimulations = passedNumberOfSimulations;
targetCOV = passedTargetCOV;
 
}
 
 
SimulationAnalysis::~SimulationAnalysis()
{
}
 
 
 
int
SimulationAnalysis::analyze(void)
{
 
// Alert the user that the simulation analysis has started
cerr << "Simulation Analysis is running ... " << endl;
 
 
// Declaration of some of the data used in the algorithm
double gFunctionValue;
int result;
int I, i, j, k;
double det_covariance;
double phi;
double h;
double q_bar, pf, cov, beta, q;
double variance_of_q_bar;
double cov_of_q_bar;
int numRV = theReliabilityDomain->getNumberOfRandomVariables();
Matrix covariance(numRV, numRV);
Matrix chol_covariance(numRV, numRV);
Matrix inv_covariance(numRV, numRV);
Vector point(numRV);
Vector startValues(numRV);
Vector x(numRV);
Vector z(numRV);
Vector u(numRV);
Vector randomArray(numRV);
RandomVariable *aRandomVariable;
LimitStateFunction *theLimitStateFunction = 0;
NormalRV *aStdNormRV = 0;
aStdNormRV = new NormalRV(1,0.0,1.0,0.0);
 
// Check if computer ran out of memory
if (aStdNormRV==0) {
cerr << "SimulationAnalysis::analyze() - out of memory while instantiating internal objects." << endl;
return -1;
}
 
// Establish covariance matrix
for (i=0; i<numRV; i++) {
for (j=0; j<numRV; j++) {
if (i==j) {
covariance(i,j) = 1.0;
}
else
covariance(i,j) = 0.0;
}
}
 
 
// Create object to do matrix operations on the covariance matrix
MatrixOperations *theMatrixOperations = 0;
theMatrixOperations = new MatrixOperations(covariance);
if (theMatrixOperations == 0) {
cerr << "SimulationAnalysis::analyze() - could not create" << endl
<< " the object to perform matrix operations." << endl;
return -1;
}
 
 
// Cholesky decomposition of covariance matrix
result = theMatrixOperations->computeLowerCholesky();
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not compute" << endl
<< " the Cholesky decomposition of the covariance matrix." << endl;
return -1;
}
chol_covariance = theMatrixOperations->getLowerCholesky();
 
 
// Inverse of covariance matrix
result = theMatrixOperations->computeInverse();
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not compute" << endl
<< " the inverse of the covariance matrix." << endl;
return -1;
}
inv_covariance = theMatrixOperations->getInverse();
 
 
// Compute the determinant, knowing that this is a diagonal matrix
result = theMatrixOperations->computeTrace();
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not compute" << endl
<< " the trace of the covariance matrix." << endl;
return -1;
}
det_covariance = theMatrixOperations->getTrace();
 
// Initializations
double sum_q;
double sum_q_squared;
 
 
// Pre-compute some factors to minimize computations inside simulation loop
double pi = 3.14159265358979;
double factor1 = 1.0 / ( pow((2.0*pi),((double)numRV/2.0)) );
double factor2 = 1.0 / ( pow((2.0*pi),((double)numRV/2.0)) * sqrt(det_covariance) );
 
 
// Number of limit-state functions
int numLsf = theReliabilityDomain->getNumberOfLimitStateFunctions();
 
 
// Loop over number of limit-state functions
for (int lsf=1; lsf<=numLsf; lsf++ ) {
 
 
// Inform the user which limit-state function is being evaluated
cerr << "Limit-state function number: " << lsf << endl;
 
 
// Set tag of "active" limit-state function
theReliabilityDomain->setTagOfActiveLimitStateFunction(lsf);
 
 
// Get the limit-state function pointer
theLimitStateFunction = 0;
lsf = theReliabilityDomain->getTagOfActiveLimitStateFunction();
theLimitStateFunction = theReliabilityDomain->getLimitStateFunctionPtr(lsf);
if (theLimitStateFunction == 0) {
cerr << "SimulationAnalysis::analyze() - could not find" << endl
<< " limit-state function with tag #" << lsf << "." << endl;
return -1;
}
 
 
// Determine the point to simulate around
if ( strcmp(pointToSampleAround, "aroundStartPoint") == 0 ) {
for ( j=1; j<=numRV; j++)
{
aRandomVariable = theReliabilityDomain->getRandomVariablePtr(j);
startValues(j-1) = aRandomVariable->getStartValue();
}
result = theXuTransformation->set_x(startValues);
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not " << endl
<< " set the x-vector for xu-transformation. " << endl;
return -1;
}
result = theXuTransformation->transform_x_to_u();
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not " << endl
<< " transform x to u. " << endl;
return -1;
}
point = theXuTransformation->get_u();
}
else if ( strcmp(pointToSampleAround, "aroundOrigin") == 0 ) {
for ( j=0; j<numRV; j++)
{
point(j) = 0.0;
}
}
else if ( strcmp(pointToSampleAround, "aroundDesignPoint") == 0 ) {
point = theLimitStateFunction->designPoint_u_inStdNormalSpace;
}
else {
cerr << "SimulationAnalysis::analyze() - " << pointToSampleAround << endl
<< " is not a valid point to sample around." << endl;
return -1;
}
 
sum_q = 0.0;
sum_q_squared = 0.0;
k = 1;
cov_of_q_bar = 999.0;
 
while( k<=numberOfSimulations && cov_of_q_bar>targetCOV ) {
 
// Create array of standard normal random numbers
result = theRandomNumberGenerator->generate_nIndependentStdNormalNumbers(numRV);
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not generate" << endl
<< " random numbers for simulation." << endl;
return -1;
}
randomArray = theRandomNumberGenerator->getGeneratedNumbers();
 
 
// Compute the point in standard normal space
u = point + chol_covariance * randomArray;
 
 
// Transform into original space
result = theXuTransformation->set_u(u);
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not " << endl
<< " set the u-vector for xu-transformation. " << endl;
return -1;
}
 
result = theXuTransformation->transform_u_to_x();
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not " << endl
<< " transform u to x. " << endl;
return -1;
}
x = theXuTransformation->get_x();
 
 
// Evaluate limit-state function
result = theGFunEvaluator->evaluate_g(x);
if (result < 0) {
cerr << "SimulationAnalysis::analyze() - could not " << endl
<< " evaluate limit-state function. " << endl;
return -1;
}
gFunctionValue = theGFunEvaluator->get_g();
 
 
// Collect result of sampling
if (gFunctionValue < 0.0) {
I = 1;
}
else {
I = 0;
}
 
// Compute values of joint distributions at the u-point
phi = factor1 * exp( -0.5 * (u ^ u) );
Vector temp1 = inv_covariance ^ (u-point);
double temp2 = temp1 ^ (u-point);
h = factor2 * exp( -0.5 * temp2 );
 
 
// Update sums
q = I * phi / h;
sum_q = sum_q + q;
sum_q_squared = sum_q_squared + q*q;
 
if (sum_q > 0 && k>5 ) {
// Compute coefficient of variation (of pf)
q_bar = 1.0/(double)k * sum_q;
 
variance_of_q_bar = 1.0/(double)k *
( 1.0/(double)k * sum_q_squared - (sum_q/(double)k)*(sum_q/(double)k));
cov_of_q_bar = sqrt(variance_of_q_bar) / q_bar;
}
else {
cov_of_q_bar = 999.0;
}
 
k++;
}
// Step 'k' back a step now that we went out
k--;
 
if (sum_q > 0) {
// Compute probability of failure and reliability index
pf = q_bar;
cov = cov_of_q_bar;
beta = -aStdNormRV->getInverseCDFvalue(pf);
}
else {
pf = 0;
cov = 0;
beta = 0;
}
 
// Store results
theLimitStateFunction->SimulationAnalysisPerformed=true;
theLimitStateFunction->SimulationReliabilityIndexBeta=beta;
theLimitStateFunction->SimulationProbabilityOfFailure_pfsim=pf;
theLimitStateFunction->CoefficientOfVariationOfPfFromSimulation=cov;
theLimitStateFunction->NumberOfSimulations=k;
}
 
delete aStdNormRV;
 
return 0;
}
 
/trunk/SRC/reliability/analysis/analysis/SystemAnalysis.cpp
1,223 → 1,223
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SystemAnalysis.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <SystemAnalysis.h>
#include <ReliabilityDomain.h>
#include <ReliabilityAnalysis.h>
#include <LimitStateFunction.h>
#include <MatrixOperations.h>
#include <NormalRV.h>
#include <math.h>
#include <fstream.h>
 
SystemAnalysis::SystemAnalysis( ReliabilityDomain *passedReliabilityDomain)
:ReliabilityAnalysis()
{
theReliabilityDomain = passedReliabilityDomain;
}
 
 
SystemAnalysis::~SystemAnalysis()
{
}
 
 
double
SystemAnalysis::getLowerBound(void)
{
return lowerBound;
}
 
 
 
double
SystemAnalysis::getUpperBound(void)
{
return upperBound;
}
 
 
 
int
SystemAnalysis::analyze(void)
{
cerr << "System Reliability Analysis is running ... " << endl;
 
// Initial declarations
double beta;
double pf1;
Vector alpha;
LimitStateFunction *theLimitStateFunction;
NormalRV aStdNormalRV(1, 0.0, 1.0, 0.0);
 
// Number of limit-state functions
int numLsf = theReliabilityDomain->getNumberOfLimitStateFunctions();
 
// Number of random variables
int nrv = theReliabilityDomain->getNumberOfRandomVariables();
 
// Allocate vectors to store ALL the betas and alphas
Vector allBetas(numLsf);
Vector allPf1s(numLsf);
Vector allAlphas(numLsf*nrv);
 
// Loop over number of limit-state functions and collect results
int i;
for (i=0; i<numLsf; i++ ) {
 
// Get FORM results from the limit-state function
theLimitStateFunction = theReliabilityDomain->getLimitStateFunctionPtr(i+1);
beta = theLimitStateFunction->FORMReliabilityIndexBeta;
pf1 = theLimitStateFunction->FORMProbabilityOfFailure_pf1;
alpha = theLimitStateFunction->normalizedNegativeGradientVectorAlpha;
 
// Put FORM results into vector of all betas and alphas
allBetas(i) = beta;
allPf1s(i) = pf1;
for (int j=0; j<nrv; j++ ) {
allAlphas((i*nrv)+j) = alpha(j);
}
}
 
// Compute vector of 'rhos', that is, dot products between the alphas
// in order of the rows (without diagonal): r12, r13, r23 for the case of 3 r.v.s
int rhosDim = (int)(0.5*(nrv*nrv-nrv));
Vector rhos(rhosDim);
int counter = 0;
double dotProduct;
for (i=0; i<numLsf; i++ ) {
for (int j=i+1; j<numLsf; j++ ) {
dotProduct = 1.0;
for ( int k=0; k<nrv; k++ ) {
dotProduct=dotProduct*allAlphas((i*nrv)+k)*allAlphas((j*nrv)+k);
}
rhos(counter) = dotProduct;
counter++;
}
}
 
// Compute the bi-variate normal distribution for all the pairs
Vector Pmn(rhosDim);
counter = 0;
double beta1;
double beta2;
int m;
for (m=0; m<numLsf; m++ ) {
for (int n=m+1; n<numLsf; n++ ) {
beta1 = allBetas(m);
beta2 = allBetas(n);
// Numerical integration with Simpsons rule
double a = 0.0; // Interval start
double b = rhos(counter); // Interval end
double integral = 0.0; // The result of integration
int n_2 = 100; // Half the number of intervals
double h = b-a; // Interval length
double fa = functionToIntegrate(a,beta1,beta2);
double fb = functionToIntegrate(b,beta1,beta2);
double sum_fx2j = 0.0;
double sum_fx2j_1 = 0.0;
for (int j=1; j<=n_2; j++) {
sum_fx2j = sum_fx2j + functionToIntegrate(((double)(j*2)*h),beta1,beta2);
sum_fx2j_1 = sum_fx2j_1 + functionToIntegrate(((double)(j*2-1)*h),beta1,beta2);
}
sum_fx2j = sum_fx2j - functionToIntegrate(b,beta1,beta2);
integral = h/3.0*(fa + 2.0*sum_fx2j + 4.0*sum_fx2j_1 + fb);
Pmn(counter) = aStdNormalRV.getCDFvalue(-beta1)
*aStdNormalRV.getCDFvalue(-beta2) + integral;
counter++;
}
}
 
// Compute lower probability bound
counter = 0;
double temp1;
double rowSum;
lowerBound = 0.0;
for ( m=0; m<numLsf; m++ ) {
rowSum = 0.0;
for ( i=0; i<numLsf; i++ ) {
for ( int j=i+1; j<numLsf; j++ ) {
if (j==m) {
rowSum += Pmn(counter);
}
counter++;
}
}
if ((allPf1s(i)-rowSum)>0.0) {
temp1 = (allPf1s(i)-rowSum);
}
else {
temp1 = 0.0;
}
lowerBound += temp1;
}
 
// Compute upper probability bound;
double largeNegativeNumber = -9999999.0;
upperBound = 0.0;
double theMaxValue = largeNegativeNumber;
for ( m=0; m<numLsf; m++ ) {
rowSum = 0.0;
counter = 0;
for ( i=0; i<numLsf; i++ ) {
for ( int j=i+1; j<numLsf; j++ ) {
if (j==m) {
if (Pmn(counter)>theMaxValue) {
theMaxValue = Pmn(counter);
}
}
counter++;
}
}
if (theMaxValue == largeNegativeNumber) {
theMaxValue = 0.0;
}
upperBound += allPf1s(m) - theMaxValue;
 
}
 
return 0;
}
 
 
 
double
SystemAnalysis::functionToIntegrate(double rho, double beta1, double beta2)
{
double pi = 3.14159265358979;
return 1.0/(2.0*pi*sqrt(1.0-rho*rho))
* exp(-(beta1*beta1+beta2*beta2-2*rho*beta1*beta2)
/(2.0*(1.0-rho*rho)));
}
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SystemAnalysis.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <SystemAnalysis.h>
#include <ReliabilityDomain.h>
#include <ReliabilityAnalysis.h>
#include <LimitStateFunction.h>
#include <MatrixOperations.h>
#include <NormalRV.h>
#include <math.h>
#include <fstream.h>
 
SystemAnalysis::SystemAnalysis( ReliabilityDomain *passedReliabilityDomain)
:ReliabilityAnalysis()
{
theReliabilityDomain = passedReliabilityDomain;
}
 
 
SystemAnalysis::~SystemAnalysis()
{
}
 
 
double
SystemAnalysis::getLowerBound(void)
{
return lowerBound;
}
 
 
 
double
SystemAnalysis::getUpperBound(void)
{
return upperBound;
}
 
 
 
int
SystemAnalysis::analyze(void)
{
cerr << "System Reliability Analysis is running ... " << endl;
 
// Initial declarations
double beta;
double pf1;
Vector alpha;
LimitStateFunction *theLimitStateFunction;
NormalRV aStdNormalRV(1, 0.0, 1.0, 0.0);
 
// Number of limit-state functions
int numLsf = theReliabilityDomain->getNumberOfLimitStateFunctions();
 
// Number of random variables
int nrv = theReliabilityDomain->getNumberOfRandomVariables();
 
// Allocate vectors to store ALL the betas and alphas
Vector allBetas(numLsf);
Vector allPf1s(numLsf);
Vector allAlphas(numLsf*nrv);
 
// Loop over number of limit-state functions and collect results
int i;
for (i=0; i<numLsf; i++ ) {
 
// Get FORM results from the limit-state function
theLimitStateFunction = theReliabilityDomain->getLimitStateFunctionPtr(i+1);
beta = theLimitStateFunction->FORMReliabilityIndexBeta;
pf1 = theLimitStateFunction->FORMProbabilityOfFailure_pf1;
alpha = theLimitStateFunction->normalizedNegativeGradientVectorAlpha;
 
// Put FORM results into vector of all betas and alphas
allBetas(i) = beta;
allPf1s(i) = pf1;
for (int j=0; j<nrv; j++ ) {
allAlphas((i*nrv)+j) = alpha(j);
}
}
 
// Compute vector of 'rhos', that is, dot products between the alphas
// in order of the rows (without diagonal): r12, r13, r23 for the case of 3 r.v.s
int rhosDim = (int)(0.5*(nrv*nrv-nrv));
Vector rhos(rhosDim);
int counter = 0;
double dotProduct;
for (i=0; i<numLsf; i++ ) {
for (int j=i+1; j<numLsf; j++ ) {
dotProduct = 1.0;
for ( int k=0; k<nrv; k++ ) {
dotProduct=dotProduct*allAlphas((i*nrv)+k)*allAlphas((j*nrv)+k);
}
rhos(counter) = dotProduct;
counter++;
}
}
 
// Compute the bi-variate normal distribution for all the pairs
Vector Pmn(rhosDim);
counter = 0;
double beta1;
double beta2;
int m;
for (m=0; m<numLsf; m++ ) {
for (int n=m+1; n<numLsf; n++ ) {
beta1 = allBetas(m);
beta2 = allBetas(n);
// Numerical integration with Simpsons rule
double a = 0.0; // Interval start
double b = rhos(counter); // Interval end
double integral = 0.0; // The result of integration
int n_2 = 100; // Half the number of intervals
double h = b-a; // Interval length
double fa = functionToIntegrate(a,beta1,beta2);
double fb = functionToIntegrate(b,beta1,beta2);
double sum_fx2j = 0.0;
double sum_fx2j_1 = 0.0;
for (int j=1; j<=n_2; j++) {
sum_fx2j = sum_fx2j + functionToIntegrate(((double)(j*2)*h),beta1,beta2);
sum_fx2j_1 = sum_fx2j_1 + functionToIntegrate(((double)(j*2-1)*h),beta1,beta2);
}
sum_fx2j = sum_fx2j - functionToIntegrate(b,beta1,beta2);
integral = h/3.0*(fa + 2.0*sum_fx2j + 4.0*sum_fx2j_1 + fb);
Pmn(counter) = aStdNormalRV.getCDFvalue(-beta1)
*aStdNormalRV.getCDFvalue(-beta2) + integral;
counter++;
}
}
 
// Compute lower probability bound
counter = 0;
double temp1;
double rowSum;
lowerBound = 0.0;
for ( m=0; m<numLsf; m++ ) {
rowSum = 0.0;
for ( i=0; i<numLsf; i++ ) {
for ( int j=i+1; j<numLsf; j++ ) {
if (j==m) {
rowSum += Pmn(counter);
}
counter++;
}
}
if ((allPf1s(i)-rowSum)>0.0) {
temp1 = (allPf1s(i)-rowSum);
}
else {
temp1 = 0.0;
}
lowerBound += temp1;
}
 
// Compute upper probability bound;
double largeNegativeNumber = -9999999.0;
upperBound = 0.0;
double theMaxValue = largeNegativeNumber;
for ( m=0; m<numLsf; m++ ) {
rowSum = 0.0;
counter = 0;
for ( i=0; i<numLsf; i++ ) {
for ( int j=i+1; j<numLsf; j++ ) {
if (j==m) {
if (Pmn(counter)>theMaxValue) {
theMaxValue = Pmn(counter);
}
}
counter++;
}
}
if (theMaxValue == largeNegativeNumber) {
theMaxValue = 0.0;
}
upperBound += allPf1s(m) - theMaxValue;
 
}
 
return 0;
}
 
 
 
double
SystemAnalysis::functionToIntegrate(double rho, double beta1, double beta2)
{
double pi = 3.14159265358979;
return 1.0/(2.0*pi*sqrt(1.0-rho*rho))
* exp(-(beta1*beta1+beta2*beta2-2*rho*beta1*beta2)
/(2.0*(1.0-rho*rho)));
}
/trunk/SRC/reliability/analysis/analysis/SORMAnalysis.h
1,61 → 1,61
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SORMAnalysis.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef SORMAnalysis_h
#define SORMAnalysis_h
 
#include <ReliabilityAnalysis.h>
#include <ReliabilityDomain.h>
#include <FindCurvatures.h>
 
class SORMAnalysis : public ReliabilityAnalysis
{
 
public:
SORMAnalysis( ReliabilityDomain *passedReliabilityDomain,
FindCurvatures *passedCurvaturesAlgorithm);
~SORMAnalysis();
 
int analyze(void);
 
protected:
 
private:
ReliabilityDomain *theReliabilityDomain;
FindCurvatures *theCurvaturesAlgorithm;
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:00 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SORMAnalysis.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef SORMAnalysis_h
#define SORMAnalysis_h
 
#include <ReliabilityAnalysis.h>
#include <ReliabilityDomain.h>
#include <FindCurvatures.h>
 
class SORMAnalysis : public ReliabilityAnalysis
{
 
public:
SORMAnalysis( ReliabilityDomain *passedReliabilityDomain,
FindCurvatures *passedCurvaturesAlgorithm);
~SORMAnalysis();
 
int analyze(void);
 
protected:
 
private:
ReliabilityDomain *theReliabilityDomain;
FindCurvatures *theCurvaturesAlgorithm;
 
};
 
#endif
/trunk/SRC/reliability/analysis/analysis/FORMAnalysis.h
1,61 → 1,61
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/FORMAnalysis.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef FORMAnalysis_h
#define FORMAnalysis_h
 
#include <ReliabilityAnalysis.h>
#include <FindDesignPoint.h>
#include <ReliabilityDomain.h>
 
class FORMAnalysis : public ReliabilityAnalysis
{
 
public:
FORMAnalysis( ReliabilityDomain *passedReliabilityDomain,
FindDesignPoint *passedFindDesignPoint);
virtual ~FORMAnalysis();
 
int analyze(void);
 
protected:
 
private:
ReliabilityDomain *theReliabilityDomain;
FindDesignPoint *theFindDesignPoint;
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:00 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/FORMAnalysis.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef FORMAnalysis_h
#define FORMAnalysis_h
 
#include <ReliabilityAnalysis.h>
#include <FindDesignPoint.h>
#include <ReliabilityDomain.h>
 
class FORMAnalysis : public ReliabilityAnalysis
{
 
public:
FORMAnalysis( ReliabilityDomain *passedReliabilityDomain,
FindDesignPoint *passedFindDesignPoint);
virtual ~FORMAnalysis();
 
int analyze(void);
 
protected:
 
private:
ReliabilityDomain *theReliabilityDomain;
FindDesignPoint *theFindDesignPoint;
 
};
 
#endif
/trunk/SRC/reliability/analysis/analysis/ReliabilityAnalysis.cpp
1,46 → 1,46
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/ReliabilityAnalysis.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <ReliabilityAnalysis.h>
 
ReliabilityAnalysis::ReliabilityAnalysis()
{
}
 
ReliabilityAnalysis::~ReliabilityAnalysis()
{
}
 
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:00 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/ReliabilityAnalysis.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <ReliabilityAnalysis.h>
 
ReliabilityAnalysis::ReliabilityAnalysis()
{
}
 
ReliabilityAnalysis::~ReliabilityAnalysis()
{
}
 
 
/trunk/SRC/reliability/analysis/analysis/SimulationAnalysis.h
1,73 → 1,73
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SimulationAnalysis.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef SimulationAnalysis_h
#define SimulationAnalysis_h
 
#include <ReliabilityAnalysis.h>
#include <ReliabilityDomain.h>
#include <XuTransformation.h>
#include <RandomNumberGenerator.h>
#include <GFunEvaluator.h>
 
class SimulationAnalysis : public ReliabilityAnalysis
{
 
public:
SimulationAnalysis( ReliabilityDomain *passedReliabilityDomain,
XuTransformation *passedXuTransformation,
GFunEvaluator *passedGFunEvaluator,
RandomNumberGenerator *passedRandomNumberGenerator,
char *passedPointToSampleAround,
int passedNumberOfSimulations,
double passedTargetCOV);
~SimulationAnalysis();
 
int analyze(void);
 
protected:
private:
ReliabilityDomain *theReliabilityDomain;
XuTransformation *theXuTransformation;
GFunEvaluator *theGFunEvaluator;
RandomNumberGenerator *theRandomNumberGenerator;
char *pointToSampleAround;
int numberOfSimulations;
double targetCOV;
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SimulationAnalysis.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef SimulationAnalysis_h
#define SimulationAnalysis_h
 
#include <ReliabilityAnalysis.h>
#include <ReliabilityDomain.h>
#include <XuTransformation.h>
#include <RandomNumberGenerator.h>
#include <GFunEvaluator.h>
 
class SimulationAnalysis : public ReliabilityAnalysis
{
 
public:
SimulationAnalysis( ReliabilityDomain *passedReliabilityDomain,
XuTransformation *passedXuTransformation,
GFunEvaluator *passedGFunEvaluator,
RandomNumberGenerator *passedRandomNumberGenerator,
char *passedPointToSampleAround,
int passedNumberOfSimulations,
double passedTargetCOV);
~SimulationAnalysis();
 
int analyze(void);
 
protected:
private:
ReliabilityDomain *theReliabilityDomain;
XuTransformation *theXuTransformation;
GFunEvaluator *theGFunEvaluator;
RandomNumberGenerator *theRandomNumberGenerator;
char *pointToSampleAround;
int numberOfSimulations;
double targetCOV;
 
};
 
#endif
/trunk/SRC/reliability/analysis/analysis/SystemAnalysis.h
1,62 → 1,62
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:16 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SystemAnalysis.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef SystemAnalysis_h
#define SystemAnalysis_h
 
#include <ReliabilityAnalysis.h>
#include <ReliabilityDomain.h>
 
class SystemAnalysis : public ReliabilityAnalysis
{
 
public:
SystemAnalysis( ReliabilityDomain *passedReliabilityDomain);
~SystemAnalysis();
 
int analyze(void);
double getLowerBound();
double getUpperBound();
 
protected:
 
private:
double lowerBound;
double upperBound;
ReliabilityDomain *theReliabilityDomain;
double functionToIntegrate(double rho, double beta1, double beta2);
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SystemAnalysis.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef SystemAnalysis_h
#define SystemAnalysis_h
 
#include <ReliabilityAnalysis.h>
#include <ReliabilityDomain.h>
 
class SystemAnalysis : public ReliabilityAnalysis
{
 
public:
SystemAnalysis( ReliabilityDomain *passedReliabilityDomain);
~SystemAnalysis();
 
int analyze(void);
double getLowerBound();
double getUpperBound();
 
protected:
 
private:
double lowerBound;
double upperBound;
ReliabilityDomain *theReliabilityDomain;
double functionToIntegrate(double rho, double beta1, double beta2);
};
 
#endif
/trunk/SRC/reliability/analysis/designPoint/FindDesignPoint.cpp
1,46 → 1,46
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:17 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/designPoint/FindDesignPoint.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <FindDesignPoint.h>
 
FindDesignPoint::FindDesignPoint()
{
}
 
FindDesignPoint::~FindDesignPoint()
{
}
 
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/designPoint/FindDesignPoint.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <FindDesignPoint.h>
 
FindDesignPoint::FindDesignPoint()
{
}
 
FindDesignPoint::~FindDesignPoint()
{
}
 
 
/trunk/SRC/reliability/analysis/designPoint/SearchWithStepSizeAndStepDirection.cpp
1,475 → 1,475
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:17 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/designPoint/SearchWithStepSizeAndStepDirection.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <SearchWithStepSizeAndStepDirection.h>
#include <FindDesignPoint.h>
#include <StepSizeRule.h>
#include <SearchDirection.h>
#include <XuTransformation.h>
#include <NatafXuTransformation.h>
#include <GFunEvaluator.h>
#include <SensitivityEvaluator.h>
#include <RandomVariable.h>
#include <CorrelationCoefficient.h>
#include <MatrixOperations.h>
#include <Matrix.h>
#include <Vector.h>
#include <GammaRV.h>
 
 
 
SearchWithStepSizeAndStepDirection::SearchWithStepSizeAndStepDirection(
int passedMaxNumberOfIterations,
double passedConvergenceCriterionE1,
double passedConvergenceCriterionE2,
GFunEvaluator *passedGFunEvaluator,
SensitivityEvaluator *passedSensitivityEvaluator,
StepSizeRule *passedStepSizeRule,
SearchDirection *passedSearchDirection,
XuTransformation *passedXuTransformation)
:FindDesignPoint()
{
maxNumberOfIterations = passedMaxNumberOfIterations;
convergenceCriterionE1 = passedConvergenceCriterionE1;
convergenceCriterionE2 = passedConvergenceCriterionE2;
theGFunEvaluator = passedGFunEvaluator;
theSensitivityEvaluator = passedSensitivityEvaluator;
theStepSizeRule = passedStepSizeRule;
theSearchDirection = passedSearchDirection;
theXuTransformation = passedXuTransformation;
}
 
 
 
SearchWithStepSizeAndStepDirection::~SearchWithStepSizeAndStepDirection()
{
}
 
 
int
SearchWithStepSizeAndStepDirection::findDesignPoint(
Vector *passedStartPoint,
ReliabilityDomain *passedReliabilityDomain)
{
// Set the start point (a data member of this class)
startPoint = passedStartPoint;
 
// Set the reliability domain (a data member of this class)
theReliabilityDomain = passedReliabilityDomain;
 
// RUN the generic algorithm
int result = doTheActualSearch(false);
 
return result;
}
 
 
 
int
SearchWithStepSizeAndStepDirection::approachDesignPointThroughOrthogonalSubspace(
Vector *passedDesignPoint_u,
int passedNumberOfAxes,
Vector *passedPrincipalAxes,
Vector *passedStartPoint,
ReliabilityDomain *passedReliabilityDomain)
{
// Set number of axes in the long vector
numberOfAxes = passedNumberOfAxes;
 
// Set the start point (a data member of this class)
startPoint = passedStartPoint;
 
// Set the start point (a data member of this class)
designPoint_uStar = passedDesignPoint_u;
 
// Set vector of principal axes (a data member of this class)
principalAxesPtr = passedPrincipalAxes;
 
// Set the reliability domain (a data member of this class)
theReliabilityDomain = passedReliabilityDomain;
 
// RUN the generic algorithm
int result = doTheActualSearch(true);
 
return result;
}
 
 
 
int
SearchWithStepSizeAndStepDirection::doTheActualSearch( bool doProjectionToOrthogonalSubspace)
{
// Get number of random variables and correlation coefficients from reliability domain
int numberOfRandomVariables = theReliabilityDomain->getNumberOfRandomVariables();
// Declaration of data used in the algorithm
int i, j;
int zeroFlag;
x(numberOfRandomVariables);
u(numberOfRandomVariables);
uSecondLast(numberOfRandomVariables);
Vector uNew(numberOfRandomVariables);
alpha (numberOfRandomVariables);
gamma (numberOfRandomVariables);
alphaSecondLast(numberOfRandomVariables);
double gFunctionValue;
Vector gradientOfgFunction(numberOfRandomVariables);
Vector gradientInStandardNormalSpace(numberOfRandomVariables);
double normOfGradient =0;
double stepSize;
Matrix jacobian_x_u(numberOfRandomVariables,numberOfRandomVariables);
Vector u_minus_alpha_u_alpha;
double alpha_times_u;
double NormOf_u_minus_alpha_u_alpha;
 
 
// Get starting point
x = *startPoint;
 
 
// Transform starting point into standard normal space
int result = theXuTransformation->set_x(x);
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not set x in the xu-transformation." << endl;
return -1;
}
 
 
result = theXuTransformation->transform_x_to_u();
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not transform from x to u." << endl;
return -1;
}
u = theXuTransformation->get_u();
 
 
// Loop to find design point
i = 1;
while ( i <= maxNumberOfIterations )
{
 
// Transform from u to x space
result = theXuTransformation->set_u(u);
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not set u in the xu-transformation." << endl;
return -1;
}
 
 
result = theXuTransformation->transform_u_to_x_andComputeJacobian();
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not transform from u to x and compute Jacobian." << endl;
return -1;
}
x = theXuTransformation->get_x();
jacobian_x_u = theXuTransformation->getJacobian_x_u();
 
 
// Evaluate limit-state function
result = theGFunEvaluator->evaluate_g(x);
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not evaluate limit-state function. " << endl;
return -1;
}
gFunctionValue = theGFunEvaluator->get_g();
 
 
// Gradient in original space
result = theSensitivityEvaluator->evaluate_grad_g(gFunctionValue,x);
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not compute gradients of the limit-state function. " << endl;
return -1;
}
gradientOfgFunction = theSensitivityEvaluator->get_grad_g();
 
 
// Check if all components of the vector is zero
zeroFlag = 0;
for (j=0; j<gradientOfgFunction.Size(); j++) {
if (gradientOfgFunction[j] != 0.0) {
zeroFlag = 1;
}
}
if (zeroFlag == 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " all components of the gradient vector is zero. " << endl;
return -1;
}
 
 
// Gradient in standard normal space
gradientInStandardNormalSpace = jacobian_x_u ^ gradientOfgFunction;
 
 
// Set scale parameter
if (i == 1)
{
Go = gFunctionValue;
}
 
 
// Compute the norm of the gradient in standard normal space
normOfGradient = gradientInStandardNormalSpace.Norm();
 
 
// Check that the norm is not zero
if (normOfGradient == 0.0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " the norm of the gradient is zero. " << endl;
return -1;
}
 
 
// Compute alpha-vector
alpha = gradientInStandardNormalSpace * ( (-1) / normOfGradient );
 
 
// Provide user with information about the current step
cerr << " Iteration #" << i << ", limit-state function value: "
<< gFunctionValue << endl;
 
 
// Check convergence
alpha_times_u = alpha ^ u;
u_minus_alpha_u_alpha = u - alpha * alpha_times_u;
NormOf_u_minus_alpha_u_alpha = u_minus_alpha_u_alpha.Norm();
if ( ( fabs(gFunctionValue / Go) < convergenceCriterionE1 ) &
( NormOf_u_minus_alpha_u_alpha < convergenceCriterionE2 ) )
{
// Compute the gamma vector if the analysis converged
MatrixOperations theMatrixOperations(jacobian_x_u);
 
 
result = theMatrixOperations.computeTranspose();
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not compute transpose of jacobian matrix. " << endl;
return -1;
}
Matrix transposeOfJacobian_x_u = theMatrixOperations.getTranspose();
 
 
Matrix jacobianProduct = jacobian_x_u * transposeOfJacobian_x_u;
 
 
theMatrixOperations.setMatrix(jacobianProduct);
result = theMatrixOperations.computeSquareRoot();
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not compute square root of matrix elements. " << endl;
return -1;
}
Matrix squareRootOfJacobianProduct = theMatrixOperations.getSquareRoot();
 
Matrix D_prime(numberOfRandomVariables,numberOfRandomVariables);
for (j=0; j<numberOfRandomVariables; j++) {
D_prime(j,j) = squareRootOfJacobianProduct(j,j);
}
 
 
Matrix jacobian_u_x = theXuTransformation->getJacobian_u_x();
 
Vector tempProduct = jacobian_u_x ^ alpha;
 
gamma = D_prime ^ tempProduct;
 
return 1;
}
 
 
// Store 'u' and 'alpha' at the second last iteration point
uSecondLast = u;
alphaSecondLast = alpha;
 
 
// Determine search direction
result = theSearchDirection->computeSearchDirection(
u, gFunctionValue, gradientInStandardNormalSpace );
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not compute search direction. " << endl;
return -1;
}
searchDirection = theSearchDirection->getSearchDirection();
 
 
// Determine step size
result = theStepSizeRule->computeStepSize(
u, gradientInStandardNormalSpace, gFunctionValue, searchDirection);
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not compute step size. " << endl;
return -1;
}
stepSize = theStepSizeRule->getStepSize();
 
 
// Determine new iteration point (take the step)
u += searchDirection * stepSize;
 
// Possibly do projection to subspace
if (doProjectionToOrthogonalSubspace) {
doProjection(u, uNew);
u = uNew;
}
 
// Increment the loop parameter
i++;
 
}
 
 
// Print a message if max number of iterations was reached
cerr << "Maximum number of iterations was reached before convergence." << endl;
 
return 0;
}
 
 
 
 
int
SearchWithStepSizeAndStepDirection::doProjection(Vector uOld, Vector uNew)
{
 
// THIS METHOD IS CURRENTLY UNDER DEVELOPMENT
 
// Initial declarations
double dNorm;
double temp;
 
// Number of random variables
int nrv = uOld.Size();
 
// Declaration of the 'current' orthogonality vector 'd' (and the whole vector of d's)
Vector d(nrv);
Vector principalAxes = *principalAxesPtr;
 
// Other auxiliary declarations
Vector uDifference(nrv);
Vector correction(nrv);
 
for (int i=0; i<numberOfAxes; i++) {
 
// Extract the current orthogonality vector
for (int j=0; j<nrv; j++) {
d(j) = principalAxes((i*nrv)+j);
}
 
// Norm of the orthogonality vector
temp = d.Norm();
dNorm = temp*temp;
 
// Compute the formula
uDifference = *designPoint_uStar - uOld;
 
double dotProduct = d ^ uDifference;
 
correction = (1.0/dNorm * dotProduct) * d;
uNew = uOld + correction;
uOld = uNew;
}
 
return 0;
}
 
 
Vector
SearchWithStepSizeAndStepDirection::get_x()
{
return x;
}
 
Vector
SearchWithStepSizeAndStepDirection::get_u()
{
return u;
}
 
Vector
SearchWithStepSizeAndStepDirection::get_alpha()
{
return alpha;
}
 
Vector
SearchWithStepSizeAndStepDirection::get_gamma()
{
return gamma;
}
 
int
SearchWithStepSizeAndStepDirection::getNumberOfIterations()
{
return i;
}
 
Vector
SearchWithStepSizeAndStepDirection::getSecondLast_u()
{
return uSecondLast;
}
 
Vector
SearchWithStepSizeAndStepDirection::getSecondLast_alpha()
{
return alphaSecondLast;
}
 
Vector
SearchWithStepSizeAndStepDirection::getLastSearchDirection()
{
return searchDirection;
}
 
double
SearchWithStepSizeAndStepDirection::getFirstGFunValue()
{
return Go;
}
 
 
 
 
 
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/designPoint/SearchWithStepSizeAndStepDirection.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <SearchWithStepSizeAndStepDirection.h>
#include <FindDesignPoint.h>
#include <StepSizeRule.h>
#include <SearchDirection.h>
#include <XuTransformation.h>
#include <NatafXuTransformation.h>
#include <GFunEvaluator.h>
#include <SensitivityEvaluator.h>
#include <RandomVariable.h>
#include <CorrelationCoefficient.h>
#include <MatrixOperations.h>
#include <Matrix.h>
#include <Vector.h>
#include <GammaRV.h>
 
 
 
SearchWithStepSizeAndStepDirection::SearchWithStepSizeAndStepDirection(
int passedMaxNumberOfIterations,
double passedConvergenceCriterionE1,
double passedConvergenceCriterionE2,
GFunEvaluator *passedGFunEvaluator,
SensitivityEvaluator *passedSensitivityEvaluator,
StepSizeRule *passedStepSizeRule,
SearchDirection *passedSearchDirection,
XuTransformation *passedXuTransformation)
:FindDesignPoint()
{
maxNumberOfIterations = passedMaxNumberOfIterations;
convergenceCriterionE1 = passedConvergenceCriterionE1;
convergenceCriterionE2 = passedConvergenceCriterionE2;
theGFunEvaluator = passedGFunEvaluator;
theSensitivityEvaluator = passedSensitivityEvaluator;
theStepSizeRule = passedStepSizeRule;
theSearchDirection = passedSearchDirection;
theXuTransformation = passedXuTransformation;
}
 
 
 
SearchWithStepSizeAndStepDirection::~SearchWithStepSizeAndStepDirection()
{
}
 
 
int
SearchWithStepSizeAndStepDirection::findDesignPoint(
Vector *passedStartPoint,
ReliabilityDomain *passedReliabilityDomain)
{
// Set the start point (a data member of this class)
startPoint = passedStartPoint;
 
// Set the reliability domain (a data member of this class)
theReliabilityDomain = passedReliabilityDomain;
 
// RUN the generic algorithm
int result = doTheActualSearch(false);
 
return result;
}
 
 
 
int
SearchWithStepSizeAndStepDirection::approachDesignPointThroughOrthogonalSubspace(
Vector *passedDesignPoint_u,
int passedNumberOfAxes,
Vector *passedPrincipalAxes,
Vector *passedStartPoint,
ReliabilityDomain *passedReliabilityDomain)
{
// Set number of axes in the long vector
numberOfAxes = passedNumberOfAxes;
 
// Set the start point (a data member of this class)
startPoint = passedStartPoint;
 
// Set the start point (a data member of this class)
designPoint_uStar = passedDesignPoint_u;
 
// Set vector of principal axes (a data member of this class)
principalAxesPtr = passedPrincipalAxes;
 
// Set the reliability domain (a data member of this class)
theReliabilityDomain = passedReliabilityDomain;
 
// RUN the generic algorithm
int result = doTheActualSearch(true);
 
return result;
}
 
 
 
int
SearchWithStepSizeAndStepDirection::doTheActualSearch( bool doProjectionToOrthogonalSubspace)
{
// Get number of random variables and correlation coefficients from reliability domain
int numberOfRandomVariables = theReliabilityDomain->getNumberOfRandomVariables();
// Declaration of data used in the algorithm
int i, j;
int zeroFlag;
x(numberOfRandomVariables);
u(numberOfRandomVariables);
uSecondLast(numberOfRandomVariables);
Vector uNew(numberOfRandomVariables);
alpha (numberOfRandomVariables);
gamma (numberOfRandomVariables);
alphaSecondLast(numberOfRandomVariables);
double gFunctionValue;
Vector gradientOfgFunction(numberOfRandomVariables);
Vector gradientInStandardNormalSpace(numberOfRandomVariables);
double normOfGradient =0;
double stepSize;
Matrix jacobian_x_u(numberOfRandomVariables,numberOfRandomVariables);
Vector u_minus_alpha_u_alpha;
double alpha_times_u;
double NormOf_u_minus_alpha_u_alpha;
 
 
// Get starting point
x = *startPoint;
 
 
// Transform starting point into standard normal space
int result = theXuTransformation->set_x(x);
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not set x in the xu-transformation." << endl;
return -1;
}
 
 
result = theXuTransformation->transform_x_to_u();
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not transform from x to u." << endl;
return -1;
}
u = theXuTransformation->get_u();
 
 
// Loop to find design point
i = 1;
while ( i <= maxNumberOfIterations )
{
 
// Transform from u to x space
result = theXuTransformation->set_u(u);
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not set u in the xu-transformation." << endl;
return -1;
}
 
 
result = theXuTransformation->transform_u_to_x_andComputeJacobian();
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not transform from u to x and compute Jacobian." << endl;
return -1;
}
x = theXuTransformation->get_x();
jacobian_x_u = theXuTransformation->getJacobian_x_u();
 
 
// Evaluate limit-state function
result = theGFunEvaluator->evaluate_g(x);
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not evaluate limit-state function. " << endl;
return -1;
}
gFunctionValue = theGFunEvaluator->get_g();
 
 
// Gradient in original space
result = theSensitivityEvaluator->evaluate_grad_g(gFunctionValue,x);
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not compute gradients of the limit-state function. " << endl;
return -1;
}
gradientOfgFunction = theSensitivityEvaluator->get_grad_g();
 
 
// Check if all components of the vector is zero
zeroFlag = 0;
for (j=0; j<gradientOfgFunction.Size(); j++) {
if (gradientOfgFunction[j] != 0.0) {
zeroFlag = 1;
}
}
if (zeroFlag == 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " all components of the gradient vector is zero. " << endl;
return -1;
}
 
 
// Gradient in standard normal space
gradientInStandardNormalSpace = jacobian_x_u ^ gradientOfgFunction;
 
 
// Set scale parameter
if (i == 1)
{
Go = gFunctionValue;
}
 
 
// Compute the norm of the gradient in standard normal space
normOfGradient = gradientInStandardNormalSpace.Norm();
 
 
// Check that the norm is not zero
if (normOfGradient == 0.0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " the norm of the gradient is zero. " << endl;
return -1;
}
 
 
// Compute alpha-vector
alpha = gradientInStandardNormalSpace * ( (-1) / normOfGradient );
 
 
// Provide user with information about the current step
cerr << " Iteration #" << i << ", limit-state function value: "
<< gFunctionValue << endl;
 
 
// Check convergence
alpha_times_u = alpha ^ u;
u_minus_alpha_u_alpha = u - alpha * alpha_times_u;
NormOf_u_minus_alpha_u_alpha = u_minus_alpha_u_alpha.Norm();
if ( ( fabs(gFunctionValue / Go) < convergenceCriterionE1 ) &
( NormOf_u_minus_alpha_u_alpha < convergenceCriterionE2 ) )
{
// Compute the gamma vector if the analysis converged
MatrixOperations theMatrixOperations(jacobian_x_u);
 
 
result = theMatrixOperations.computeTranspose();
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not compute transpose of jacobian matrix. " << endl;
return -1;
}
Matrix transposeOfJacobian_x_u = theMatrixOperations.getTranspose();
 
 
Matrix jacobianProduct = jacobian_x_u * transposeOfJacobian_x_u;
 
 
theMatrixOperations.setMatrix(jacobianProduct);
result = theMatrixOperations.computeSquareRoot();
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not compute square root of matrix elements. " << endl;
return -1;
}
Matrix squareRootOfJacobianProduct = theMatrixOperations.getSquareRoot();
 
Matrix D_prime(numberOfRandomVariables,numberOfRandomVariables);
for (j=0; j<numberOfRandomVariables; j++) {
D_prime(j,j) = squareRootOfJacobianProduct(j,j);
}
 
 
Matrix jacobian_u_x = theXuTransformation->getJacobian_u_x();
 
Vector tempProduct = jacobian_u_x ^ alpha;
 
gamma = D_prime ^ tempProduct;
 
return 1;
}
 
 
// Store 'u' and 'alpha' at the second last iteration point
uSecondLast = u;
alphaSecondLast = alpha;
 
 
// Determine search direction
result = theSearchDirection->computeSearchDirection(
u, gFunctionValue, gradientInStandardNormalSpace );
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not compute search direction. " << endl;
return -1;
}
searchDirection = theSearchDirection->getSearchDirection();
 
 
// Determine step size
result = theStepSizeRule->computeStepSize(
u, gradientInStandardNormalSpace, gFunctionValue, searchDirection);
if (result < 0) {
cerr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endl
<< " could not compute step size. " << endl;
return -1;
}
stepSize = theStepSizeRule->getStepSize();
 
 
// Determine new iteration point (take the step)
u += searchDirection * stepSize;
 
// Possibly do projection to subspace
if (doProjectionToOrthogonalSubspace) {
doProjection(u, uNew);
u = uNew;
}
 
// Increment the loop parameter
i++;
 
}
 
 
// Print a message if max number of iterations was reached
cerr << "Maximum number of iterations was reached before convergence." << endl;
 
return 0;
}
 
 
 
 
int
SearchWithStepSizeAndStepDirection::doProjection(Vector uOld, Vector uNew)
{
 
// THIS METHOD IS CURRENTLY UNDER DEVELOPMENT
 
// Initial declarations
double dNorm;
double temp;
 
// Number of random variables
int nrv = uOld.Size();
 
// Declaration of the 'current' orthogonality vector 'd' (and the whole vector of d's)
Vector d(nrv);
Vector principalAxes = *principalAxesPtr;
 
// Other auxiliary declarations
Vector uDifference(nrv);
Vector correction(nrv);
 
for (int i=0; i<numberOfAxes; i++) {
 
// Extract the current orthogonality vector
for (int j=0; j<nrv; j++) {
d(j) = principalAxes((i*nrv)+j);
}
 
// Norm of the orthogonality vector
temp = d.Norm();
dNorm = temp*temp;
 
// Compute the formula
uDifference = *designPoint_uStar - uOld;
 
double dotProduct = d ^ uDifference;
 
correction = (1.0/dNorm * dotProduct) * d;
uNew = uOld + correction;
uOld = uNew;
}
 
return 0;
}
 
 
Vector
SearchWithStepSizeAndStepDirection::get_x()
{
return x;
}
 
Vector
SearchWithStepSizeAndStepDirection::get_u()
{
return u;
}
 
Vector
SearchWithStepSizeAndStepDirection::get_alpha()
{
return alpha;
}
 
Vector
SearchWithStepSizeAndStepDirection::get_gamma()
{
return gamma;
}
 
int
SearchWithStepSizeAndStepDirection::getNumberOfIterations()
{
return i;
}
 
Vector
SearchWithStepSizeAndStepDirection::getSecondLast_u()
{
return uSecondLast;
}
 
Vector
SearchWithStepSizeAndStepDirection::getSecondLast_alpha()
{
return alphaSecondLast;
}
 
Vector
SearchWithStepSizeAndStepDirection::getLastSearchDirection()
{
return searchDirection;
}
 
double
SearchWithStepSizeAndStepDirection::getFirstGFunValue()
{
return Go;
}
 
 
 
 
 
 
/trunk/SRC/reliability/analysis/designPoint/FindDesignPoint.h
1,75 → 1,75
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:17 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/designPoint/FindDesignPoint.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef FindDesignPoint_h
#define FindDesignPoint_h
 
#include <ReliabilityDomain.h>
#include <Vector.h>
 
class FindDesignPoint
{
 
public:
FindDesignPoint();
virtual ~FindDesignPoint();
 
virtual int findDesignPoint(Vector *startPoint,
ReliabilityDomain *theReliabilityDomain) =0;
virtual int approachDesignPointThroughOrthogonalSubspace(
Vector *designPoint,
int numberOfAxes,
Vector *allPrincipalAxes,
Vector *startPoint,
ReliabilityDomain *theReliabilityDomain) =0;
 
virtual Vector get_x() =0;
virtual Vector get_u() =0;
virtual Vector get_alpha() =0;
virtual Vector get_gamma() =0;
virtual int getNumberOfIterations() =0;
virtual Vector getSecondLast_u() =0;
virtual Vector getSecondLast_alpha() =0;
virtual Vector getLastSearchDirection() =0;
virtual double getFirstGFunValue() =0;
 
 
protected:
 
private:
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/designPoint/FindDesignPoint.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef FindDesignPoint_h
#define FindDesignPoint_h
 
#include <ReliabilityDomain.h>
#include <Vector.h>
 
class FindDesignPoint
{
 
public:
FindDesignPoint();
virtual ~FindDesignPoint();
 
virtual int findDesignPoint(Vector *startPoint,
ReliabilityDomain *theReliabilityDomain) =0;
virtual int approachDesignPointThroughOrthogonalSubspace(
Vector *designPoint,
int numberOfAxes,
Vector *allPrincipalAxes,
Vector *startPoint,
ReliabilityDomain *theReliabilityDomain) =0;
 
virtual Vector get_x() =0;
virtual Vector get_u() =0;
virtual Vector get_alpha() =0;
virtual Vector get_gamma() =0;
virtual int getNumberOfIterations() =0;
virtual Vector getSecondLast_u() =0;
virtual Vector getSecondLast_alpha() =0;
virtual Vector getLastSearchDirection() =0;
virtual double getFirstGFunValue() =0;
 
 
protected:
 
private:
 
};
 
#endif
/trunk/SRC/reliability/analysis/designPoint/SearchWithStepSizeAndStepDirection.h
1,124 → 1,124
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:17 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/designPoint/SearchWithStepSizeAndStepDirection.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef SearchWithStepSizeAndStepDirection_h
#define SearchWithStepSizeAndStepDirection_h
 
#include <FindDesignPoint.h>
#include <StepSizeRule.h>
#include <SearchDirection.h>
#include <XuTransformation.h>
#include <GFunEvaluator.h>
#include <SensitivityEvaluator.h>
#include <Matrix.h>
#include <Vector.h>
#include <ReliabilityDomain.h>
 
class SearchWithStepSizeAndStepDirection : public FindDesignPoint
{
 
public:
 
// Constructor and destructor
SearchWithStepSizeAndStepDirection(
int passedMaxNumberOfIterations,
double passedConvergenceCriterionE1,
double passedConvergenceCriterionE2,
GFunEvaluator *passedGFunEvaluator,
SensitivityEvaluator *passedSensitivityEvaluator,
StepSizeRule *passedStepSizeRule,
SearchDirection *passedSearchDirection,
XuTransformation *passedXuTransformation);
~SearchWithStepSizeAndStepDirection();
int findDesignPoint(Vector *startPoint,
ReliabilityDomain *theReliabilityDomain);
int approachDesignPointThroughOrthogonalSubspace(
Vector *designPoint,
int numberOfAxesInVector,
Vector *principalAxes,
Vector *startPoint,
ReliabilityDomain *theReliabilityDomain);
Vector get_x();
Vector get_u();
Vector get_alpha();
Vector get_gamma();
int getNumberOfIterations();
Vector getSecondLast_u();
Vector getSecondLast_alpha();
Vector getLastSearchDirection();
double getFirstGFunValue();
 
protected:
 
private:
 
// The reliability domain and tools for the analysis
ReliabilityDomain *theReliabilityDomain;
GFunEvaluator *theGFunEvaluator;
SensitivityEvaluator *theSensitivityEvaluator;
StepSizeRule *theStepSizeRule;
SearchDirection *theSearchDirection;
XuTransformation *theXuTransformation;
 
// Private member functions to do the job
int doTheActualSearch(bool doProjection);
int doProjection(Vector uOld, Vector uNew);
 
// Data members set when the object is created
int maxNumberOfIterations;
double convergenceCriterionE1;
double convergenceCriterionE2;
 
// Data members where the results are to be stored
Vector x;
Vector u;
Vector alpha;
Vector gamma;
Vector uSecondLast;
Vector alphaSecondLast;
int i;
Vector searchDirection;
double Go;
 
// Data members set through the call when a job is to be done
Vector *startPoint;
Vector *designPoint_uStar;
int numberOfAxes;
Vector *principalAxesPtr;
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:01 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/designPoint/SearchWithStepSizeAndStepDirection.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef SearchWithStepSizeAndStepDirection_h
#define SearchWithStepSizeAndStepDirection_h
 
#include <FindDesignPoint.h>
#include <StepSizeRule.h>
#include <SearchDirection.h>
#include <XuTransformation.h>
#include <GFunEvaluator.h>
#include <SensitivityEvaluator.h>
#include <Matrix.h>
#include <Vector.h>
#include <ReliabilityDomain.h>
 
class SearchWithStepSizeAndStepDirection : public FindDesignPoint
{
 
public:
 
// Constructor and destructor
SearchWithStepSizeAndStepDirection(
int passedMaxNumberOfIterations,
double passedConvergenceCriterionE1,
double passedConvergenceCriterionE2,
GFunEvaluator *passedGFunEvaluator,
SensitivityEvaluator *passedSensitivityEvaluator,
StepSizeRule *passedStepSizeRule,
SearchDirection *passedSearchDirection,
XuTransformation *passedXuTransformation);
~SearchWithStepSizeAndStepDirection();
int findDesignPoint(Vector *startPoint,
ReliabilityDomain *theReliabilityDomain);
int approachDesignPointThroughOrthogonalSubspace(
Vector *designPoint,
int numberOfAxesInVector,
Vector *principalAxes,
Vector *startPoint,
ReliabilityDomain *theReliabilityDomain);
Vector get_x();
Vector get_u();
Vector get_alpha();
Vector get_gamma();
int getNumberOfIterations();
Vector getSecondLast_u();
Vector getSecondLast_alpha();
Vector getLastSearchDirection();
double getFirstGFunValue();
 
protected:
 
private:
 
// The reliability domain and tools for the analysis
ReliabilityDomain *theReliabilityDomain;
GFunEvaluator *theGFunEvaluator;
SensitivityEvaluator *theSensitivityEvaluator;
StepSizeRule *theStepSizeRule;
SearchDirection *theSearchDirection;
XuTransformation *theXuTransformation;
 
// Private member functions to do the job
int doTheActualSearch(bool doProjection);
int doProjection(Vector uOld, Vector uNew);
 
// Data members set when the object is created
int maxNumberOfIterations;
double convergenceCriterionE1;
double convergenceCriterionE2;
 
// Data members where the results are to be stored
Vector x;
Vector u;
Vector alpha;
Vector gamma;
Vector uSecondLast;
Vector alphaSecondLast;
int i;
Vector searchDirection;
double Go;
 
// Data members set through the call when a job is to be done
Vector *startPoint;
Vector *designPoint_uStar;
int numberOfAxes;
Vector *principalAxesPtr;
 
};
 
#endif
/trunk/SRC/reliability/analysis/stepSize/ArmijoRule.h
1,63 → 1,63
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:19 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/ArmijoRule.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef ArmijoRule_h
#define ArmijoRule_h
 
#include <StepSizeRule.h>
#include <GFunEvaluator.h>
#include <XuTransformation.h>
 
class ArmijoRule : public StepSizeRule
{
 
public:
ArmijoRule(GFunEvaluator *passedGFunEvaluator,
XuTransformation *passedXuTransformation);
~ArmijoRule();
 
int computeStepSize(Vector u, Vector grad_G, double G, Vector d);
double getStepSize();
 
protected:
 
private:
double stepSize;
GFunEvaluator *theGFunEvaluator;
XuTransformation *theXuTransformation;
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:02 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/ArmijoRule.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef ArmijoRule_h
#define ArmijoRule_h
 
#include <StepSizeRule.h>
#include <GFunEvaluator.h>
#include <XuTransformation.h>
 
class ArmijoRule : public StepSizeRule
{
 
public:
ArmijoRule(GFunEvaluator *passedGFunEvaluator,
XuTransformation *passedXuTransformation);
~ArmijoRule();
 
int computeStepSize(Vector u, Vector grad_G, double G, Vector d);
double getStepSize();
 
protected:
 
private:
double stepSize;
GFunEvaluator *theGFunEvaluator;
XuTransformation *theXuTransformation;
 
};
 
#endif
/trunk/SRC/reliability/analysis/stepSize/FixedStepSizeRule.cpp
1,76 → 1,76
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:19 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/FixedStepSizeRule.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <FixedStepSizeRule.h>
#include <StepSizeRule.h>
#include <XuTransformation.h>
#include <math.h>
#include <Vector.h>
 
 
FixedStepSizeRule::FixedStepSizeRule(double passedStepSize)
:StepSizeRule()
{
stepSize = passedStepSize;
}
 
FixedStepSizeRule::~FixedStepSizeRule()
{
}
 
 
 
int
FixedStepSizeRule::computeStepSize(Vector u,
Vector grad_G,
double G,
Vector d)
{
// This method is in fact not neccesary
// for the fixed step size rule. The
// user has already given the step size.
 
return 0;
 
}
 
 
double
FixedStepSizeRule::getStepSize()
{
return stepSize;
 
}
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:02 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/FixedStepSizeRule.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <FixedStepSizeRule.h>
#include <StepSizeRule.h>
#include <XuTransformation.h>
#include <math.h>
#include <Vector.h>
 
 
FixedStepSizeRule::FixedStepSizeRule(double passedStepSize)
:StepSizeRule()
{
stepSize = passedStepSize;
}
 
FixedStepSizeRule::~FixedStepSizeRule()
{
}
 
 
 
int
FixedStepSizeRule::computeStepSize(Vector u,
Vector grad_G,
double G,
Vector d)
{
// This method is in fact not neccesary
// for the fixed step size rule. The
// user has already given the step size.
 
return 0;
 
}
 
 
double
FixedStepSizeRule::getStepSize()
{
return stepSize;
 
}
 
/trunk/SRC/reliability/analysis/stepSize/StepSizeRule.cpp
1,45 → 1,45
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:19 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/StepSizeRule.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <StepSizeRule.h>
 
StepSizeRule::StepSizeRule()
{
}
 
StepSizeRule::~StepSizeRule()
{
}
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:03 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/StepSizeRule.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <StepSizeRule.h>
 
StepSizeRule::StepSizeRule()
{
}
 
StepSizeRule::~StepSizeRule()
{
}
 
/trunk/SRC/reliability/analysis/stepSize/FixedStepSizeRule.h
1,58 → 1,58
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:19 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/FixedStepSizeRule.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef FixedStepSizeRule_h
#define FixedStepSizeRule_h
 
#include <StepSizeRule.h>
 
class FixedStepSizeRule : public StepSizeRule
{
 
public:
FixedStepSizeRule(double stepSize);
~FixedStepSizeRule();
 
int computeStepSize(Vector u, Vector grad_G, double G, Vector d);
double getStepSize();
 
protected:
 
private:
double stepSize;
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:03 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/FixedStepSizeRule.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef FixedStepSizeRule_h
#define FixedStepSizeRule_h
 
#include <StepSizeRule.h>
 
class FixedStepSizeRule : public StepSizeRule
{
 
public:
FixedStepSizeRule(double stepSize);
~FixedStepSizeRule();
 
int computeStepSize(Vector u, Vector grad_G, double G, Vector d);
double getStepSize();
 
protected:
 
private:
double stepSize;
 
};
 
#endif
/trunk/SRC/reliability/analysis/stepSize/StepSizeRule.h
1,57 → 1,57
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:19 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/StepSizeRule.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef StepSizeRule_h
#define StepSizeRule_h
 
#include <Vector.h>
 
class StepSizeRule
{
 
public:
StepSizeRule();
virtual ~StepSizeRule();
 
virtual int computeStepSize(Vector u, Vector grad_G, double G, Vector d) =0;
virtual double getStepSize() =0;
 
protected:
 
private:
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:03 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/StepSizeRule.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef StepSizeRule_h
#define StepSizeRule_h
 
#include <Vector.h>
 
class StepSizeRule
{
 
public:
StepSizeRule();
virtual ~StepSizeRule();
 
virtual int computeStepSize(Vector u, Vector grad_G, double G, Vector d) =0;
virtual double getStepSize() =0;
 
protected:
 
private:
 
};
 
#endif
/trunk/SRC/reliability/analysis/stepSize/ArmijoRule.cpp
1,186 → 1,186
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:19 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/ArmijoRule.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <ArmijoRule.h>
#include <StepSizeRule.h>
#include <XuTransformation.h>
#include <math.h>
#include <Vector.h>
 
 
ArmijoRule::ArmijoRule(GFunEvaluator *passedGFunEvaluator,
XuTransformation *passedXuTransformation)
:StepSizeRule()
{
theGFunEvaluator = passedGFunEvaluator;
theXuTransformation = passedXuTransformation;
 
}
 
ArmijoRule::~ArmijoRule()
{
}
 
 
 
double
ArmijoRule::getStepSize()
{
return stepSize;
}
 
 
 
 
int
ArmijoRule::computeStepSize(Vector u,
Vector grad_G,
double G,
Vector d)
{
// Check that the norm of the gradient is not zero
double gradNorm = grad_G.Norm();
if (gradNorm == 0.0) {
cerr << "ArmijoRule::computeStepSize() - the norm " << endl
<< " of the gradient is zero. " << endl;
return -1;
}
 
// Compute factor 'c'
double c = ( u.Norm() / gradNorm ) * 2.0 + 10.0;
 
 
// Compute merit function
double merit = 0.5 * u.Norm() * u.Norm() + c * fabs(G);
 
// Set the first trial step size to '1.0'
double trial_step_size = 1.0;
 
// Take a trial step in standard normal space
Vector trial_u = u + d * trial_step_size;
 
 
// Transform the trial point into original space
double result = theXuTransformation->set_u(trial_u);
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not set " << endl
<< " vector u in the xu-transformation. " << endl;
return -1;
}
result = theXuTransformation->transform_u_to_x();
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not " << endl
<< " transform u to x. " << endl;
return -1;
}
Vector trial_x = theXuTransformation->get_x();
 
// Evaluate the limit-state function
result = theGFunEvaluator->evaluate_g(trial_x);
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not " << endl
<< " evaluate the limit-state function. " << endl;
return -1;
}
double trial_G = theGFunEvaluator->get_g();
 
 
// Compute merit function again, based on the new limit-state function value
double merit_new = 0.5 * trial_u.Norm() * trial_u.Norm() + c * fabs(trial_G);
 
 
// If the merit function did not decrease, we try to
// repeatedly reduce the step size until it does.
int i = 1;
while ( (merit_new > merit) && (i<6) ) {
 
// Update merit function value
merit = merit_new;
 
 
// Cut the step size in half and try that instead
trial_step_size = trial_step_size * 0.5;
trial_u = u + d * trial_step_size;
 
 
// Transform the trial point into original space
double result = theXuTransformation->set_u(trial_u);
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not set " << endl
<< " vector u in the xu-transformation. " << endl;
return -1;
}
result = theXuTransformation->transform_u_to_x();
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not " << endl
<< " transform u to x. " << endl;
return -1;
}
Vector trial_x = theXuTransformation->get_x();
 
 
// Evaluate the limit-state function
result = theGFunEvaluator->evaluate_g(trial_x);
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not " << endl
<< " evaluate the limit-state function. " << endl;
return -1;
}
double trial_G = theGFunEvaluator->get_g();
 
 
// Compute merit function again, based on the new limit-state function value
merit_new = 0.5 * trial_u.Norm() * trial_u.Norm() + c * fabs(trial_G);
 
// Increment counter
i++;
 
 
// Report to user if the step reduction was not successful
if (i==5 && merit_new > merit ) {
cerr << "ArmijoRule::computeStepSize() - tried to half step size 5 times." << endl;
}
}
 
stepSize = trial_step_size;
 
return 0;
 
}
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:02 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/stepSize/ArmijoRule.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <ArmijoRule.h>
#include <StepSizeRule.h>
#include <XuTransformation.h>
#include <math.h>
#include <Vector.h>
 
 
ArmijoRule::ArmijoRule(GFunEvaluator *passedGFunEvaluator,
XuTransformation *passedXuTransformation)
:StepSizeRule()
{
theGFunEvaluator = passedGFunEvaluator;
theXuTransformation = passedXuTransformation;
 
}
 
ArmijoRule::~ArmijoRule()
{
}
 
 
 
double
ArmijoRule::getStepSize()
{
return stepSize;
}
 
 
 
 
int
ArmijoRule::computeStepSize(Vector u,
Vector grad_G,
double G,
Vector d)
{
// Check that the norm of the gradient is not zero
double gradNorm = grad_G.Norm();
if (gradNorm == 0.0) {
cerr << "ArmijoRule::computeStepSize() - the norm " << endl
<< " of the gradient is zero. " << endl;
return -1;
}
 
// Compute factor 'c'
double c = ( u.Norm() / gradNorm ) * 2.0 + 10.0;
 
 
// Compute merit function
double merit = 0.5 * u.Norm() * u.Norm() + c * fabs(G);
 
// Set the first trial step size to '1.0'
double trial_step_size = 1.0;
 
// Take a trial step in standard normal space
Vector trial_u = u + d * trial_step_size;
 
 
// Transform the trial point into original space
double result = theXuTransformation->set_u(trial_u);
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not set " << endl
<< " vector u in the xu-transformation. " << endl;
return -1;
}
result = theXuTransformation->transform_u_to_x();
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not " << endl
<< " transform u to x. " << endl;
return -1;
}
Vector trial_x = theXuTransformation->get_x();
 
// Evaluate the limit-state function
result = theGFunEvaluator->evaluate_g(trial_x);
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not " << endl
<< " evaluate the limit-state function. " << endl;
return -1;
}
double trial_G = theGFunEvaluator->get_g();
 
 
// Compute merit function again, based on the new limit-state function value
double merit_new = 0.5 * trial_u.Norm() * trial_u.Norm() + c * fabs(trial_G);
 
 
// If the merit function did not decrease, we try to
// repeatedly reduce the step size until it does.
int i = 1;
while ( (merit_new > merit) && (i<6) ) {
 
// Update merit function value
merit = merit_new;
 
 
// Cut the step size in half and try that instead
trial_step_size = trial_step_size * 0.5;
trial_u = u + d * trial_step_size;
 
 
// Transform the trial point into original space
double result = theXuTransformation->set_u(trial_u);
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not set " << endl
<< " vector u in the xu-transformation. " << endl;
return -1;
}
result = theXuTransformation->transform_u_to_x();
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not " << endl
<< " transform u to x. " << endl;
return -1;
}
Vector trial_x = theXuTransformation->get_x();
 
 
// Evaluate the limit-state function
result = theGFunEvaluator->evaluate_g(trial_x);
if (result < 0) {
cerr << "ArmijoRule::computeStepSize() - could not " << endl
<< " evaluate the limit-state function. " << endl;
return -1;
}
double trial_G = theGFunEvaluator->get_g();
 
 
// Compute merit function again, based on the new limit-state function value
merit_new = 0.5 * trial_u.Norm() * trial_u.Norm() + c * fabs(trial_G);
 
// Increment counter
i++;
 
 
// Report to user if the step reduction was not successful
if (i==5 && merit_new > merit ) {
cerr << "ArmijoRule::computeStepSize() - tried to half step size 5 times." << endl;
}
}
 
stepSize = trial_step_size;
 
return 0;
 
}
/trunk/SRC/reliability/analysis/transformation/NatafXuTransformation.h
1,89 → 1,89
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:20 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/transformation/NatafXuTransformation.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef NatafXuTransformation_h
#define NatafXuTransformation_h
 
#include <Vector.h>
#include <Matrix.h>
#include <ReliabilityDomain.h>
#include <MatrixOperations.h>
 
class NatafXuTransformation : public XuTransformation
{
 
public:
NatafXuTransformation(ReliabilityDomain *passedReliabilityDomain);
~NatafXuTransformation();
 
int set_x(Vector x);
int set_u(Vector u);
 
int transform_x_to_u();
int transform_u_to_x();
int transform_u_to_x_andComputeJacobian();
 
 
Vector get_x();
Vector get_u();
Matrix getJacobian_x_u();
Matrix getJacobian_u_x();
 
protected:
 
private:
 
// Private data members
Vector *x;
Vector *u;
Matrix *jacobian_x_u;
Matrix *jacobian_u_x;
ReliabilityDomain *theReliabilityDomain;
MatrixOperations *theMatrixOperations;
int nrv;
Matrix *correlationMatrix;
Matrix *lowerCholesky;
Matrix *inverseLowerCholesky;
 
// Private member functions
void setCorrelationMatrix();
Matrix getJacobian_z_x(Vector x, Vector z);
Vector z_to_x(Vector z);
Vector x_to_z(Vector x);
 
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:03 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/transformation/NatafXuTransformation.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef NatafXuTransformation_h
#define NatafXuTransformation_h
 
#include <Vector.h>
#include <Matrix.h>
#include <ReliabilityDomain.h>
#include <MatrixOperations.h>
 
class NatafXuTransformation : public XuTransformation
{
 
public:
NatafXuTransformation(ReliabilityDomain *passedReliabilityDomain);
~NatafXuTransformation();
 
int set_x(Vector x);
int set_u(Vector u);
 
int transform_x_to_u();
int transform_u_to_x();
int transform_u_to_x_andComputeJacobian();
 
 
Vector get_x();
Vector get_u();
Matrix getJacobian_x_u();
Matrix getJacobian_u_x();
 
protected:
 
private:
 
// Private data members
Vector *x;
Vector *u;
Matrix *jacobian_x_u;
Matrix *jacobian_u_x;
ReliabilityDomain *theReliabilityDomain;
MatrixOperations *theMatrixOperations;
int nrv;
Matrix *correlationMatrix;
Matrix *lowerCholesky;
Matrix *inverseLowerCholesky;
 
// Private member functions
void setCorrelationMatrix();
Matrix getJacobian_z_x(Vector x, Vector z);
Vector z_to_x(Vector z);
Vector x_to_z(Vector x);
 
 
};
 
#endif
/trunk/SRC/reliability/analysis/transformation/XuTransformation.cpp
1,46 → 1,46
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:20 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/transformation/XuTransformation.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <XuTransformation.h>
 
XuTransformation::XuTransformation()
{
}
 
XuTransformation::~XuTransformation()
{
}
 
 
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:03 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/transformation/XuTransformation.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <XuTransformation.h>
 
XuTransformation::XuTransformation()
{
}
 
XuTransformation::~XuTransformation()
{
}
 
 
/trunk/SRC/reliability/analysis/transformation/XuTransformation.h
1,67 → 1,67
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:20 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/transformation/XuTransformation.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef XuTransformation_h
#define XuTransformation_h
 
#include <Vector.h>
#include <Matrix.h>
 
class XuTransformation
{
 
public:
XuTransformation();
virtual ~XuTransformation();
 
virtual int set_x(Vector x) =0;
virtual int set_u(Vector u) =0;
 
virtual int transform_x_to_u() =0;
virtual int transform_u_to_x() =0;
virtual int transform_u_to_x_andComputeJacobian() =0;
 
virtual Vector get_x() =0;
virtual Vector get_u() =0;
virtual Matrix getJacobian_x_u() =0;
virtual Matrix getJacobian_u_x() =0;
 
protected:
 
private:
 
};
 
#endif
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2001-06-14 08:06:03 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/transformation/XuTransformation.h,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#ifndef XuTransformation_h
#define XuTransformation_h
 
#include <Vector.h>
#include <Matrix.h>
 
class XuTransformation
{
 
public:
XuTransformation();
virtual ~XuTransformation();
 
virtual int set_x(Vector x) =0;
virtual int set_u(Vector u) =0;
 
virtual int transform_x_to_u() =0;
virtual int transform_u_to_x() =0;
virtual int transform_u_to_x_andComputeJacobian() =0;
 
virtual Vector get_x() =0;
virtual Vector get_u() =0;
virtual Matrix getJacobian_x_u() =0;
virtual Matrix getJacobian_u_x() =0;
 
protected:
 
private:
 
};
 
#endif
/trunk/SRC/reliability/analysis/transformation/NatafXuTransformation.cpp
1,1054 → 1,1054
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.1 $
// $Date: 2001-06-13 05:06:19 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/transformation/NatafXuTransformation.cpp,v $
 
 
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) during Spring 2000
// Revised: haukaas 06/00 (core code)
// haukaas 06/01 (made part of official OpenSees)
//
 
#include <XuTransformation.h>
#include <NatafXuTransformation.h>
#include <RandomVariable.h>
#include <CorrelationCoefficient.h>
#include <NormalRV.h>
#include <Vector.h>
#include <Matrix.h>
#include <MatrixOperations.h>
#include <math.h>
#include <string.h>
 
 
NatafXuTransformation::NatafXuTransformation(ReliabilityDomain *passedReliabilityDomain)
:XuTransformation()
{
theReliabilityDomain = passedReliabilityDomain;
 
 
// Find and set problem size (number of random variables)
nrv = theReliabilityDomain->getNumberOfRandomVariables();
 
 
// Create/initialize vectors and matrices
x = new Vector(nrv);
u = new Vector(nrv);
jacobian_x_u = new Matrix(nrv,nrv);
jacobian_u_x = new Matrix(nrv,nrv);
lowerCholesky = new Matrix(nrv,nrv);
inverseLowerCholesky = new Matrix(nrv,nrv);
 
 
// Establish correlation matrix according to the Nataf assumption
setCorrelationMatrix();
 
 
// Create object to do matrix operations on the correlation matrix
theMatrixOperations = 0;
theMatrixOperations = new MatrixOperations(*correlationMatrix);
if (theMatrixOperations == 0) {
cerr << "NatafXuTransformation::NatafXuTransformation() - could " << endl
<< " not create the object to perform matrix operations." << endl;
}
 
 
// Cholesky decomposition of correlation matrix
int result = theMatrixOperations->computeCholeskyAndItsInverse();
if (result < 0) {
cerr << "NatafXuTransformation::NatafXuTransformation() - could not" << endl
<< " compute the Cholesky decomposition and its inverse " << endl
<< " for the correlation matrix." << endl;
}
(*lowerCholesky) = theMatrixOperations->getLowerCholesky();
(*inverseLowerCholesky) = theMatrixOperations->getInverseLowerCholesky();
 
}
 
NatafXuTransformation::~NatafXuTransformation()
{
delete correlationMatrix;
delete lowerCholesky;
delete inverseLowerCholesky;
delete jacobian_x_u;
delete jacobian_u_x;
delete x;
delete u;
delete theMatrixOperations;
}
 
 
 
int
NatafXuTransformation::set_x(Vector passedx)
{
(*x) = passedx; // (later: check size of vector, etc.)
return 0;
}
 
int
NatafXuTransformation::set_u(Vector passedu)
{
(*u) = passedu; // (later: check size of vector, etc.)
return 0;
}
 
int
NatafXuTransformation::transform_x_to_u()
{
Vector z = x_to_z(*x);
(*u) = (*inverseLowerCholesky) * z;
return 0;
}
 
int
NatafXuTransformation::transform_u_to_x()
{
Vector z = (*lowerCholesky) * (*u);
(*x) = z_to_x(z);
 
return 0;
}
 
 
int
NatafXuTransformation::transform_u_to_x_andComputeJacobian()
{
Vector z = (*lowerCholesky) * (*u);
(*x) = z_to_x(z);
 
 
Matrix Jzx = getJacobian_z_x((*x),z);
(*jacobian_u_x) = (*inverseLowerCholesky) * Jzx;
 
 
int result = theMatrixOperations->setMatrix((*jacobian_u_x));
if (result < 0) {
cerr << "NatafXuTransformation::transform_u_to_x() - could not set " << endl
<< " the matrix in the object to perform matrix operations." << endl;
return -1;
}
 
result = theMatrixOperations->computeInverse();
if (result < 0) {
cerr << "NatafXuTransformation::transform_u_to_x() - could not " << endl
<< " invert Jacobian_u_x." << endl;
return -1;
}
(*jacobian_x_u) = theMatrixOperations->getInverse();
 
return 0;
}
 
 
 
 
 
 
 
Vector
NatafXuTransformation::get_x()
{
return (*x);
}
 
 
 
Vector
NatafXuTransformation::get_u()
{
return (*u);
}
 
 
 
Matrix
NatafXuTransformation::getJacobian_x_u()
{
return (*jacobian_x_u);
}
 
 
 
Matrix
NatafXuTransformation::getJacobian_u_x()
{
return (*jacobian_u_x);
}
 
 
 
 
 
 
 
Matrix
NatafXuTransformation::getJacobian_z_x(Vector x, Vector z)
{
RandomVariable *theRV;
NormalRV aStandardNormalRV(1, 0.0, 1.0, 0.0);
Matrix jacobianMatrix_z_x(nrv,nrv);
for ( int i=0 ; i<nrv ; i++ )
{
theRV = theReliabilityDomain->getRandomVariablePtr(i+1);
if (strcmp(theRV->getType(),"NORMAL")==0) {
double sigma = theRV->getParameter2();
jacobianMatrix_z_x(i,i) = 1.0 / sigma;
}
else if (strcmp(theRV->getType(),"LOGNORMAL")==0) {
double zeta = theRV->getParameter2();
jacobianMatrix_z_x(i,i) = 1.0 / ( zeta * x(i) );
}
else {
jacobianMatrix_z_x(i,i) = theRV->getPDFvalue(x(i)) / aStandardNormalRV.getPDFvalue(z(i));
if (jacobianMatrix_z_x(i,i)==0.0) {
}
}
}
 
return jacobianMatrix_z_x;
}
 
 
 
 
Vector
NatafXuTransformation::z_to_x(Vector z)
{
RandomVariable *theRV;
NormalRV aStandardNormalRV(1, 0.0, 1.0, 0.0);
Vector x(nrv);
for ( int i=0 ; i<nrv ; i++ )
{
theRV = theReliabilityDomain->getRandomVariablePtr(i+1);
if (strcmp(theRV->getType(),"NORMAL")==0) {
double mju = theRV->getParameter1();
double sigma = theRV->getParameter2();
x(i) = z(i) * sigma + mju;
}
else if (strcmp(theRV->getType(),"LOGNORMAL")==0) {
double lambda = theRV->getParameter1();
double zeta = theRV->getParameter2();
x(i) = exp ( z(i) * zeta + lambda );
}
else {
x(i) = theRV->getInverseCDFvalue(aStandardNormalRV.getCDFvalue(z(i)));
}
}
return x;
}
 
 
 
 
 
Vector
NatafXuTransformation::x_to_z(Vector x)
{
RandomVariable *theRV;
NormalRV aStandardNormalRV(1, 0.0, 1.0, 0.0);
Vector z(nrv);
for ( int i=0 ; i<nrv ; i++ )
{
theRV = theReliabilityDomain->getRandomVariablePtr(i+1);
if (strcmp(theRV->getType(),"NORMAL")==0) {
double mju = theRV->getParameter1();
double sigma = theRV->getParameter2();
z(i) = ( x(i) - mju ) / sigma;
}
else if (strcmp(theRV->getType(),"LOGNORMAL")==0) {
double lambda = theRV->getParameter1();
double zeta = theRV->getParameter2();
z(i) = ( log ( x(i) ) - lambda ) / zeta;
}
else {
z(i) = aStandardNormalRV.getInverseCDFvalue(theRV->getCDFvalue(x(i)));
}
}
return z;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
void
NatafXuTransformation::setCorrelationMatrix()
{
// Initial declarations
char* typeRv1;
char* typeRv2;
int rv1;
int rv2;
RandomVariable *rv1Ptr;
RandomVariable *rv2Ptr;
double correlation;
double newCorrelation;
 
// Initialize correlation matrix
correlationMatrix = new Matrix(nrv,nrv);
 
// Put 'ones' on the diagonal
for ( int i=0 ; i<nrv ; i++ )
{
(*correlationMatrix)(i,i) = 1.0;
}
 
// Get number of correlation coefficients
int numberOfCorrelationCoefficients =
theReliabilityDomain->getNumberOfCorrelationCoefficients();
 
// Modify each coefficient at a time and put it into the correlation matrix
for ( int j=1 ; j<=numberOfCorrelationCoefficients ; j++ )
{
// Get a pointer to the correlation coefficient with tag 'j'
CorrelationCoefficient *theCorrelationCoefficient =
theReliabilityDomain->getCorrelationCoefficientPtr(j);
 
// Get value of the correlation
correlation = theCorrelationCoefficient->getCorrelation();
 
// Get tags for the two involved random variables
rv1 = theCorrelationCoefficient->getRv1();
rv2 = theCorrelationCoefficient->getRv2();
 
// Get pointers to the two random variables
rv1Ptr = theReliabilityDomain->getRandomVariablePtr(rv1);
rv2Ptr = theReliabilityDomain->getRandomVariablePtr(rv2);
 
// Get the types of the two random variables
typeRv1 = rv1Ptr->getType();
typeRv2 = rv2Ptr->getType();
 
// Compute the coefficient of variation of the random variables
double cov1 = rv1Ptr->getStdv() / rv1Ptr->getMean();
double cov2 = rv2Ptr->getStdv() / rv2Ptr->getMean();
 
// Modify the correlation coefficient according to
// the type of the the two involved random variables
 
/////////////////////////////////////////////////////////////////////////////////
if ( strcmp(typeRv1," NORMAL") == 0 && strcmp(typeRv2,"LOGNORMAL") == 0 ) {
double zeta2 = sqrt ( log ( 1.0 + cov2 * cov2 ) );
newCorrelation = correlation * cov2 / zeta2;
}
else if ( strcmp(typeRv1,"NORMAL") == 0 && strcmp(typeRv2,"GAMMA") == 0 ) {
newCorrelation = (1.001 - 0.007 * cov2 + 0.118 * cov2 * cov2) * correlation;
}
else if ( strcmp(typeRv1,"NORMAL") == 0 && (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) ) {
newCorrelation = 1.107 * correlation;
}
else if ( strcmp(typeRv1,"NORMAL") == 0 && (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) ) {
newCorrelation = 1.014 * correlation;
}
else if ( strcmp(typeRv1,"NORMAL") == 0 && strcmp(typeRv2,"UNIFORM") == 0 ) {
newCorrelation = 1.023 * correlation;
}
else if ( strcmp(typeRv1,"NORMAL") == 0 && strcmp(typeRv2,"BETA") == 0 ) {
double ba = rv2Ptr->getParameter4() - rv2Ptr->getParameter3();
double u2 = ( rv2Ptr->getMean() - rv2Ptr->getParameter3() ) / ba;
double s2 = rv2Ptr->getStdv() / ba;
newCorrelation = (1.026 + 0.001*correlation - 0.178*u2
+ 0.268*s2 - 0.001*correlation*correlation
+ 0.178*u2*u2 - 0.679*s2*s2 - 0.003*s2*correlation) * correlation;
}
else if ( strcmp(typeRv1,"NORMAL") == 0 && (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) ) {
newCorrelation = 1.031 * correlation;
}
else if ( strcmp(typeRv1,"NORMAL") == 0 && strcmp(typeRv2,"TYPE1SMALLESTVALAUE") == 0 ) {
newCorrelation = 1.031 * correlation;
}
else if ( strcmp(typeRv1,"NORMAL") == 0 && strcmp(typeRv2,"TYPE2LARGESTVALUE") == 0 ) {
newCorrelation = (1.030 + 0.238*cov2 + 0.364*cov2*cov2) * correlation;
}
else if ( strcmp(typeRv1,"NORMAL") == 0 && (strcmp(typeRv2,"TYPE3SMALLESTVALUE") == 0 || strcmp(typeRv2,"WEIBULL") == 0) ) {
newCorrelation = (1.031 - 0.195*cov2 + 0.328*cov2*cov2) * correlation;
}
/////////////////////////////////////////////////////////////////////////////////
else if ( strcmp(typeRv1,"LOGNORMAL") == 0 && strcmp(typeRv2,"NORMAL") == 0 ) {
double zeta1 = sqrt ( log ( 1 + pow ( cov1 , 2 ) ) );
newCorrelation = correlation * cov1 / zeta1;
}
else if ( strcmp(typeRv1,"LOGNORMAL") == 0 && strcmp(typeRv2,"LOGNORMAL") == 0 ) {
double zeta1 = sqrt ( log ( 1.0 + cov1*cov1 ) );
double zeta2 = sqrt ( log ( 1.0 + cov2*cov2 ) );
newCorrelation = 1.0 / ( zeta1 * zeta2 ) * log ( 1 + correlation * cov1 * cov2 );
}
else if ( strcmp(typeRv1,"LOGNORMAL") == 0 && strcmp(typeRv2,"GAMMA") == 0 ) {
double temp = 1.001 + 0.033*correlation + 0.004*cov1 - 0.016*cov2
+ 0.002*correlation*correlation + 0.223*cov1*cov1 + 0.0130*cov2*cov2;
newCorrelation = correlation * (temp - 0.104*correlation*cov1 + 0.029*cov1*cov2 - 0.119*correlation*cov2);
}
else if ( strcmp(typeRv1,"LOGNORMAL") == 0 && (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) ) {
newCorrelation = (1.098 + 0.003*correlation + 0.019*cov1 + 0.025*correlation*correlation
+ 0.303*cov1*cov1 - 0.437*correlation*cov1) * correlation;
}
else if ( strcmp(typeRv1,"LOGNORMAL") == 0 && (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) ) {
newCorrelation = (1.011 + 0.001*correlation + 0.014*cov1 + 0.004*correlation*correlation
+ 0.231*cov1*cov1 - 0.130*correlation*cov1) * correlation;
}
else if ( strcmp(typeRv1,"LOGNORMAL") == 0 && strcmp(typeRv2,"UNIFORM") == 0 ) {
newCorrelation = (1.019 + 0.014*cov1 + 0.010*correlation*correlation + 0.249*cov1*cov1)*correlation;
}
else if ( strcmp(typeRv1,"LOGNORMAL") == 0 && strcmp(typeRv2,"BETA") == 0 ) {
double ba = rv2Ptr->getParameter4() - rv2Ptr->getParameter3();
double u2 = ( rv2Ptr->getMean() - rv2Ptr->getParameter3() ) / ba;
double s2 = rv2Ptr->getStdv() / ba;
double uu = u2*u2;
double ss = s2*s2;
double xu = correlation * u2;
double xs = correlation * s2;
double us = u2*s2;
double up = u2*cov1;
double sp = s2 * cov1;
double temp = 0.979 + 0.053*correlation + 0.181*u2 + 0.293*s2 + 0.002*cov1
- 0.004*correlation*correlation - 0.181*uu + 5.796*ss + 0.277*cov1*cov1 - 0.107*xu
- 0.619*xs - 0.190*correlation*cov1 - 3.976*us - 0.097*up + 0.133*sp
- 14.402*ss*s2 - 0.069*cov1*cov1*cov1
+ 0.031*correlation*xs + 0.015*correlation*correlation*cov1
+ 3.976*uu*s2 + 0.097*uu*cov1 - 0.430*ss*cov1
+ 0.113*sp*cov1 + 1.239*correlation*us + 0.380*correlation*up;
newCorrelation = temp * correlation;
}
else if ( strcmp(typeRv1,"LOGNORMAL") == 0 && (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) ) {
newCorrelation = (1.029 + 0.001*correlation + 0.014*cov1 + 0.004*correlation*correlation
+ 0.233*cov1*cov1 - 0.197*correlation*cov1)*correlation;
}
else if ( strcmp(typeRv1,"LOGNORMAL") == 0 && strcmp(typeRv2,"TYPE1SMALLESTVALAUE") == 0 ) {
newCorrelation = (1.029 - 0.001*correlation + 0.014*cov1 + 0.004*correlation*correlation
+ 0.233*cov1*cov1 + 0.197*correlation*cov1) * correlation;
}
else if ( strcmp(typeRv1,"LOGNORMAL") == 0 && strcmp(typeRv2,"TYPE2LARGESTVALUE") == 0 ) {
double temp = 1.026 + 0.082*correlation - 0.019*cov1 + 0.222*cov2 + 0.018*correlation*correlation
+ 0.288*cov1*cov1 + 0.379*cov2*cov2;
newCorrelation = (temp - 0.441*correlation*cov1 + 0.126*cov1*cov2 - 0.277*correlation*cov2);
}
else if ( strcmp(typeRv1,"LOGNORMAL") == 0 && (strcmp(typeRv2,"TYPE3SMALLESTVALUE") == 0 || strcmp(typeRv2,"WEIBULL") == 0) ) {
double temp = 1.031+0.052*correlation+0.011*cov1-0.210*cov2+0.002*correlation*correlation+0.220*cov1*cov1+0.350*cov2*cov2;
newCorrelation = (temp+0.005*correlation*cov1+0.009*cov1*cov2-0.174*correlation*cov2)*correlation;
}
/////////////////////////////////////////////////////////////////////////////////
else if ( strcmp(typeRv1,"GAMMA") == 0 && strcmp(typeRv2,"NORMAL") == 0 ) {
newCorrelation = (1.001 - 0.007 * cov1 + 0.118 * cov1 * cov1) * correlation;
}
else if ( strcmp(typeRv1,"GAMMA") == 0 && strcmp(typeRv2,"LOGNORMAL") == 0 ) {
double temp = 1.001 + 0.033*correlation + 0.004*cov2 - 0.016*cov1
+ 0.002*correlation*correlation + 0.223*cov2*cov2 + 0.0130*cov1*cov1;
newCorrelation = correlation * (temp - 0.104*correlation*cov2 + 0.029*cov2*cov1 - 0.119*correlation*cov1);
}
else if ( strcmp(typeRv1,"GAMMA") == 0 && strcmp(typeRv2,"GAMMA") == 0 ) {
double temp = 1.002+0.022*correlation-0.012*(cov1+cov2)+0.001*correlation*correlation+0.125*(cov1*cov1+cov2*cov2);
newCorrelation = (temp-0.077*(correlation*cov1+correlation*cov2)+0.014*cov1*cov2)*correlation;
}
else if ( strcmp(typeRv1,"GAMMA") == 0 && (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) ) {
newCorrelation = (1.104+0.003*correlation-0.008*cov1+0.014*correlation*correlation+0.173*cov1*cov1-0.296*correlation*cov1)*correlation;
}
else if ( strcmp(typeRv1,"GAMMA") == 0 && (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) ) {
newCorrelation = (1.014+0.001*correlation-0.007*cov1+0.002*correlation*correlation+0.126*cov1*cov1-0.090*correlation*cov1)*correlation;
}
else if ( strcmp(typeRv1,"GAMMA") == 0 && strcmp(typeRv2,"UNIFORM") == 0 ) {
newCorrelation = (1.023+0.000*correlation-0.007*cov1+0.002*correlation*correlation+0.127*cov1*cov1-0.000*correlation*cov1)*correlation;
}
else if ( strcmp(typeRv1,"GAMMA") == 0 && strcmp(typeRv2,"BETA") == 0 ) {
double ba = rv2Ptr->getParameter4() - rv2Ptr->getParameter3();
double u2 = ( rv2Ptr->getMean() - rv2Ptr->getParameter3() ) / ba;
double s2 = rv2Ptr->getStdv() / ba;
double uu=u2*u2;
double ss=s2*s2;
double xu=correlation*u2;
double xs=correlation*s2;
double us=u2*s2;
double up=u2*cov1;
double sp=s2*cov1;
double temp;
double xp=correlation*cov1;
if(correlation > 0.0) {
temp = 0.931+0.050*correlation+0.366*u2+0.549*s2+0.181*cov1
-0.055*correlation*correlation-0.515*uu+4.804*ss-0.484*cov1*cov1-0.064*xu
-0.637*xs+0.032*xp-4.059*us-0.319*up-0.211*sp
+0.052*correlation*correlation*correlation+0.227*uu*u2-10.220*ss*s2+0.559*cov1*cov1*cov1-0.042*correlation*xu
+0.223*correlation*xs-0.172*correlation*xp+0.028*correlation*uu+0.695*correlation*ss+0.126*correlation*cov1*cov1
+3.845*uu*s2+0.019*uu*cov1-1.244*us*s2+0.008*up*cov1-2.075*ss*cov1
+0.167*sp*cov1+0.666*correlation*us+0.386*correlation*up-0.517*correlation*sp+2.125*us*cov1;
}
else {
temp = 1.025+0.050*correlation-0.029*u2+0.047*s2-0.136*cov1
+0.069*correlation*correlation+0.178*uu+6.281*ss+0.548*cov1*cov1-0.027*xu
-0.686*xs+0.046*xp-3.513*us+0.231*up+0.299*sp
+0.063*correlation*correlation*correlation-0.226*uu*u2-17.507*ss*s2-0.366*cov1*cov1*cov1+0.051*correlation*xu
-0.246*correlation*xs+0.186*correlation*xp-0.001*correlation*uu+0.984*correlation*ss+0.121*correlation*cov1*cov1
+3.700*uu*s2+0.081*uu*cov1+1.356*us*s2+0.002*up*cov1+1.654*ss*cov1
-0.135*sp*cov1+0.619*correlation*us+0.410*correlation*up-0.686*correlation*sp-2.205*us*cov1;
}
newCorrelation = temp*correlation;
}
else if ( strcmp(typeRv1,"GAMMA") == 0 && (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) ) {
newCorrelation = (1.031+0.001*correlation-0.007*cov1+0.003*correlation*correlation+0.131*cov1*cov1-0.132*correlation*cov1)*correlation;
}
else if ( strcmp(typeRv1,"GAMMA") == 0 && strcmp(typeRv2,"TYPE1SMALLESTVALAUE") == 0 ) {
newCorrelation = (1.031-0.001*correlation-0.007*cov1+0.003*correlation*correlation+0.131*cov1*cov1+0.132*correlation*cov1)*correlation;
}
else if ( strcmp(typeRv1,"GAMMA") == 0 && strcmp(typeRv2,"TYPE2LARGESTVALUE") == 0 ) {
double temp = 1.029+0.056*correlation-0.030*cov1+0.225*cov2+0.012*correlation*correlation+0.174*cov1*cov1+0.379*cov2*cov2;
newCorrelation = (temp-0.313*correlation*cov1+0.075*cov1*cov2-0.182*correlation*cov2)*correlation;
}
else if ( strcmp(typeRv1,"GAMMA") == 0 && (strcmp(typeRv2,"TYPE3SMALLESTVALUE") == 0 || strcmp(typeRv2,"WEIBULL") == 0) ) {
double temp = 1.032+0.034*correlation-0.007*cov1-0.202*cov2+0.000*correlation*correlation+0.121*cov1*cov1+0.339*cov2*cov2;
newCorrelation = (temp-0.006*correlation*cov1+0.003*cov1*cov2-0.111*correlation*cov2)*correlation;
}
/////////////////////////////////////////////////////////////////////////////////
else if ( (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) && strcmp(typeRv2,"NORMAL") == 0 ) {
newCorrelation = 1.107 * correlation;
}
else if ( (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) && strcmp(typeRv2,"LOGNORMAL") == 0 ) {
newCorrelation = (1.098 + 0.003*correlation + 0.019*cov2 + 0.025*correlation*correlation
+ 0.303*cov2*cov2 - 0.437*correlation*cov2) * correlation;
}
else if ( (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) && strcmp(typeRv2,"GAMMA") == 0 ) {
newCorrelation = (1.104+0.003*correlation-0.008*cov2+0.014*correlation*correlation+0.173*cov2*cov2-0.296*correlation*cov2)*correlation;
}
else if ( (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) && (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) ) {
newCorrelation = (1.229-0.367*correlation+0.153*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) && (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) ) {
newCorrelation = (1.123-0.100*correlation+0.021*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) && strcmp(typeRv2,"UNIFORM") == 0 ) {
newCorrelation = (1.133+0.029*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) && strcmp(typeRv2,"BETA") == 0 ) {
double ba = rv2Ptr->getParameter4() - rv2Ptr->getParameter3();
double u2 = ( rv2Ptr->getMean() - rv2Ptr->getParameter3() ) / ba;
double s2 = rv2Ptr->getStdv() / ba;
double uu=u2*u2;
double ss=s2*s2;
double xu=correlation*u2;
double xs=correlation*s2;
double us=u2*s2;
double temp = 1.082-0.004*correlation+0.204*u2+0.432*s2-0.001*correlation*correlation
- 0.204*uu+7.728*ss+0.008*xu-1.699*xs-5.338*us
- 19.741*ss*s2+0.135*correlation*xs+5.338*uu*s2+3.397*correlation*us;
newCorrelation = temp*correlation;
}
else if ( (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) && (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) ) {
newCorrelation = (1.142-0.154*correlation+0.031*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) && strcmp(typeRv2,"TYPE1SMALLESTVALAUE") == 0 ) {
newCorrelation = (1.142+0.154*correlation+0.031*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) && strcmp(typeRv2,"TYPE2LARGESTVALUE") == 0 ) {
newCorrelation = (1.109-0.152*correlation+0.361*cov2+0.130*correlation*correlation+0.455*cov2*cov2-0.728*correlation*cov2)*correlation;
}
else if ( (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) && (strcmp(typeRv2,"TYPE3SMALLESTVALUE") == 0 || strcmp(typeRv2,"WEIBULL") == 0) ) {
newCorrelation = (1.147+0.145*correlation-0.271*cov2+0.010*correlation*correlation+0.459*cov2*cov2-0.467*correlation*cov2)*correlation;
}
/////////////////////////////////////////////////////////////////////////////////
else if ( (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) && strcmp(typeRv2,"NORMAL") == 0 ) {
newCorrelation = 1.014 * correlation;
}
else if ( (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) && strcmp(typeRv2,"LOGNORMAL") == 0 ) {
newCorrelation = (1.011 + 0.001*correlation + 0.014*cov2 + 0.004*correlation*correlation
+ 0.231*cov2*cov2 - 0.130*correlation*cov2) * correlation;
}
else if ( (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) && strcmp(typeRv2,"GAMMA") == 0 ) {
newCorrelation = (1.014+0.001*correlation-0.007*cov2+0.002*correlation*correlation+0.126*cov2*cov2-0.090*correlation*cov2)*correlation;
}
else if ( (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) && (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) ) {
newCorrelation = (1.123-0.100*correlation+0.021*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) && (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) ) {
newCorrelation = (1.028-0.029*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) && strcmp(typeRv2,"UNIFORM") == 0 ) {
newCorrelation = (1.038-0.008*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) && strcmp(typeRv2,"BETA") == 0 ) {
double ba = rv2Ptr->getParameter4() - rv2Ptr->getParameter3();
double u2 = ( rv2Ptr->getMean() - rv2Ptr->getParameter3() ) / ba;
double s2 = rv2Ptr->getStdv() / ba;
double temp = 1.037-0.042*correlation-0.182*u2+0.369*s2-0.001*correlation*correlation
+0.182*u2*u2-1.150*s2*s2+0.084*correlation*u2;
newCorrelation = temp*correlation;
}
else if ( (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) && (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) ) {
newCorrelation = (1.046-0.045*correlation+0.006*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) && strcmp(typeRv2,"TYPE1SMALLESTVALAUE") == 0 ) {
newCorrelation = (1.046+0.045*correlation+0.006*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) && strcmp(typeRv2,"TYPE2LARGESTVALUE") == 0 ) {
newCorrelation = (1.036-0.038*correlation+0.266*cov2+0.028*correlation*correlation+0.383*cov2*cov2-0.229*correlation*cov2)*correlation;
}
else if ( (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) && (strcmp(typeRv2,"TYPE3SMALLESTVALUE") == 0 || strcmp(typeRv2,"WEIBULL") == 0) ) {
newCorrelation = (1.047+0.042*correlation-0.212*cov2+0.353*cov2*cov2-0.136*correlation*cov2)*correlation;
}
/////////////////////////////////////////////////////////////////////////////////
else if ( strcmp(typeRv1,"UNIFORM") == 0 && strcmp(typeRv2,"NORMAL") == 0 ) {
newCorrelation = 1.023 * correlation;
}
else if ( strcmp(typeRv1,"UNIFORM") == 0 && strcmp(typeRv2,"LOGNORMAL") == 0 ) {
newCorrelation = (1.019 + 0.014*cov2 + 0.010*correlation*correlation + 0.249*cov2*cov2)*correlation;
}
else if ( strcmp(typeRv1,"UNIFORM") == 0 && strcmp(typeRv2,"GAMMA") == 0 ) {
newCorrelation = (1.023+0.000*correlation-0.007*cov2+0.002*correlation*correlation+0.127*cov2*cov2-0.000*correlation*cov2)*correlation;
}
else if ( strcmp(typeRv1,"UNIFORM") == 0 && (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) ) {
newCorrelation = (1.133+0.029*correlation*correlation)*correlation;
}
else if ( strcmp(typeRv1,"UNIFORM") == 0 && (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) ) {
newCorrelation = (1.038-0.008*correlation*correlation)*correlation;
}
else if ( strcmp(typeRv1,"UNIFORM") == 0 && strcmp(typeRv2,"UNIFORM") == 0 ) {
newCorrelation = (1.047-0.047*correlation*correlation)*correlation;
}
else if ( strcmp(typeRv1,"UNIFORM") == 0 && strcmp(typeRv2,"BETA") == 0 ) {
double ba = rv2Ptr->getParameter4() - rv2Ptr->getParameter3();
double u2 = ( rv2Ptr->getMean() - rv2Ptr->getParameter3() ) / ba;
double s2 = rv2Ptr->getStdv() / ba;
double temp = 1.040+0.015*correlation-0.176*u2+0.432*s2-0.008*correlation*correlation
+0.176*u2*u2-1.286*s2*s2-0.137*correlation*s2;
newCorrelation = temp * correlation;
}
else if ( strcmp(typeRv1,"UNIFORM") == 0 && (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) ) {
newCorrelation = (1.055+0.015*correlation*correlation)*correlation;
}
else if ( strcmp(typeRv1,"UNIFORM") == 0 && strcmp(typeRv2,"TYPE1SMALLESTVALAUE") == 0 ) {
newCorrelation = (1.055+0.015*correlation*correlation)*correlation;
}
else if ( strcmp(typeRv1,"UNIFORM") == 0 && strcmp(typeRv2,"TYPE2LARGESTVALUE") == 0 ) {
newCorrelation = (1.033+0.305*cov2+0.074*correlation*correlation+0.405*cov2*cov2)*correlation;
}
else if ( strcmp(typeRv1,"UNIFORM") == 0 && (strcmp(typeRv2,"TYPE3SMALLESTVALUE") == 0 || strcmp(typeRv2,"WEIBULL") == 0) ) {
newCorrelation = (1.061-0.237*cov2-0.005*correlation*correlation+0.379*cov2*cov2)*correlation;
}
/////////////////////////////////////////////////////////////////////////////////
else if ( strcmp(typeRv1,"BETA") == 0 && strcmp(typeRv2,"NORMAL") == 0 ) {
double ba = rv1Ptr->getParameter4() - rv1Ptr->getParameter3();
double u1 = ( rv1Ptr->getMean() - rv1Ptr->getParameter3() ) / ba;
double s1 = rv1Ptr->getStdv() / ba;
newCorrelation = (1.026 + 0.001*correlation - 0.178*u1
+ 0.268*s1 - 0.001*correlation*correlation
+ 0.178*u1*u1 - 0.679*s1*s1 - 0.003*s1*correlation) * correlation;
 
}
else if ( strcmp(typeRv1,"BETA") == 0 && strcmp(typeRv2,"LOGNORMAL") == 0 ) {
double ba = rv1Ptr->getParameter4() - rv1Ptr->getParameter3();
double u1 = ( rv1Ptr->getMean() - rv1Ptr->getParameter3() ) / ba;
double s1 = rv1Ptr->getStdv() / ba;
double uu = u1*u1;
double ss = s1*s1;
double xu = correlation * u1;
double xs = correlation * s1;
double us = u1*s1;
double up = u1*cov2;
double sp = s1 * cov2;
double temp = 0.979 + 0.053*correlation + 0.181*u1 + 0.293*s1 + 0.002*cov2
- 0.004*correlation*correlation - 0.181*uu + 5.796*ss + 0.277*cov2*cov2 - 0.107*xu
- 0.619*xs - 0.190*correlation*cov2 - 3.976*us - 0.097*up + 0.133*sp
- 14.402*ss*s1 - 0.069*cov2*cov2*cov2
+ 0.031*correlation*xs + 0.015*correlation*correlation*cov2
+ 3.976*uu*s1 + 0.097*uu*cov2 - 0.430*ss*cov2
+ 0.113*sp*cov2 + 1.239*correlation*us + 0.380*correlation*up;
newCorrelation = temp * correlation;
 
}
else if ( strcmp(typeRv1,"BETA") == 0 && strcmp(typeRv2,"GAMMA") == 0 ) {
double ba2 = rv2Ptr->getParameter4() - rv2Ptr->getParameter3();
double u2 = ( rv2Ptr->getMean() - rv2Ptr->getParameter3() ) / ba2;
double s2 = rv2Ptr->getStdv() / ba2;
double ba = rv1Ptr->getParameter4() - rv1Ptr->getParameter3();
double u1 = ( rv1Ptr->getMean() - rv1Ptr->getParameter3() ) / ba;
double s1 = rv1Ptr->getStdv() / ba;
double uu=u1*u1;
double ss=s1*s1;
double xu=correlation*u1;
double xs=correlation*s1;
double us=u1*s1;
double up=u1*cov2;
double sp=s1*cov2;
double temp;
double xp=correlation*cov2;
if(correlation > 0.0) {
temp = 0.931+0.050*correlation+0.366*u1+0.549*s1+0.181*cov2
-0.055*correlation*correlation-0.515*uu+4.804*ss-0.484*cov2*cov2-0.064*xu
-0.637*xs+0.032*xp-4.059*us-0.319*up-0.211*sp
+0.052*correlation*correlation*correlation+0.227*uu*u2-10.220*ss*s2+0.559*cov2*cov2*cov2-0.042*correlation*xu
+0.223*correlation*xs-0.172*correlation*xp+0.028*correlation*uu+0.695*correlation*ss+0.126*correlation*cov2*cov2
+3.845*uu*s2+0.019*uu*cov2-1.244*us*s1+0.008*up*cov2-2.075*ss*cov2
+0.167*sp*cov2+0.666*correlation*us+0.386*correlation*up-0.517*correlation*sp+2.125*us*cov2;
}
else {
temp = 1.025+0.050*correlation-0.029*u1+0.047*s1-0.136*cov2
+0.069*correlation*correlation+0.178*uu+6.281*ss+0.548*cov2*cov2-0.027*xu
-0.686*xs+0.046*xp-3.513*us+0.231*up+0.299*sp
+0.063*correlation*correlation*correlation-0.226*uu*u1-17.507*ss*s2-0.366*cov2*cov2*cov2+0.051*correlation*xu
-0.246*correlation*xs+0.186*correlation*xp-0.001*correlation*uu+0.984*correlation*ss+0.121*correlation*cov2*cov2
+3.700*uu*s1+0.081*uu*cov2+1.356*us*s1+0.002*up*cov2+1.654*ss*cov2
-0.135*sp*cov2+0.619*correlation*us+0.410*correlation*up-0.686*correlation*sp-2.205*us*cov2;
}
newCorrelation = temp*correlation;
 
}
else if ( strcmp(typeRv1,"BETA") == 0 && (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) ) {
double ba = rv1Ptr->getParameter4() - rv1Ptr->getParameter3();
double u1 = ( rv1Ptr->getMean() - rv1Ptr->getParameter3() ) / ba;
double s1 = rv1Ptr->getStdv() / ba;
double ba2 = rv2Ptr->getParameter4() - rv2Ptr->getParameter3();
double u2 = ( rv2Ptr->getMean() - rv2Ptr->getParameter3() ) / ba2;
double s2 = rv2Ptr->getStdv() / ba2;
double uu=u1*u1;
double ss=s1*s1;
double xu=correlation*u1;
double xs=correlation*s1;
double us=u1*s1;
double temp = 1.082-0.004*correlation+0.204*u1+0.432*s1-0.001*correlation*correlation
- 0.204*uu+7.728*ss+0.008*xu-1.699*xs-5.338*us
- 19.741*ss*s2+0.135*correlation*xs+5.338*uu*s1+3.397*correlation*us;
newCorrelation = temp*correlation;
 
}
else if ( strcmp(typeRv1,"BETA") == 0 && (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) ) {
double ba = rv1Ptr->getParameter4() - rv1Ptr->getParameter3();
double u1 = ( rv1Ptr->getMean() - rv1Ptr->getParameter3() ) / ba;
double s1 = rv1Ptr->getStdv() / ba;
double temp = 1.037-0.042*correlation-0.182*u1+0.369*s1-0.001*correlation*correlation
+0.182*u1*u1-1.150*s1*s1+0.084*correlation*u1;
newCorrelation = temp*correlation;
}
else if ( strcmp(typeRv1,"BETA") == 0 && strcmp(typeRv2,"UNIFORM") == 0 ) {
double ba = rv1Ptr->getParameter4() - rv1Ptr->getParameter3();
double u1 = ( rv1Ptr->getMean() - rv1Ptr->getParameter3() ) / ba;
double s1 = rv1Ptr->getStdv() / ba;
double temp = 1.040+0.015*correlation-0.176*u1+0.432*s1-0.008*correlation*correlation
+0.176*u1*u1-1.286*s1*s1-0.137*correlation*s1;
newCorrelation = temp * correlation;
}
else if ( strcmp(typeRv1,"BETA") == 0 && strcmp(typeRv2,"BETA") == 0 ) {
double ba1 = rv1Ptr->getParameter4() - rv1Ptr->getParameter3();
double u1 = ( rv1Ptr->getMean() - rv1Ptr->getParameter3() ) / ba1;
double s1 = rv1Ptr->getStdv() / ba1;
double ba2 = rv2Ptr->getParameter4() - rv2Ptr->getParameter3();
double u2 = ( rv2Ptr->getMean() - rv2Ptr->getParameter3() ) / ba2;
double s2 = rv2Ptr->getStdv() / ba2;
double o=u1;
double p=s1;
double q=u2;
double r=s2;
double u=o+q;
double s=p+r;
double oo=o*o;
double pp=p*cov1;
double qq=q*q;
double rr=r*r;
double oq=o*q;
double pr=p*r;
double us=oo+cov2*cov2;
double ss=cov1*cov1+rr;
double uc=oo*o+cov2*cov2*q;
double sc=cov1*cov1*cov1+rr*r;
double x=correlation;
double xx=correlation*correlation;
double temp;
if(correlation > 0.0) {
temp =1.030-0.050*x-0.056*u+0.094*s+0.009*xx-0.084*us+2.583*ss
+0.100*x*u+0.010*x*s-0.485*u*s+0.270*oq-0.688*pr-0.011*xx*x
+0.024*uc-10.786*sc+0.013*xx*u-0.035*xx*s+0.001*x*us-0.069*x*ss
+1.174*us*s+0.004*oq*u+0.227*ss*u+2.783*pr*s+0.058*x*s*u
-0.260*x*oq-0.352*x*pr-1.609*oq*s+0.194*pr*u;
}
else {
temp=0.939-0.023*x+0.147*u+0.668*s+0.035*xx-0.008*us+3.146*ss
+0.103*x*u-0.126*x*s-1.866*u*s-0.268*oq-0.304*pr+0.011*xx*x
-0.024*uc-10.836*sc-0.013*xx*u-0.035*xx*s-0.001*x*us+0.069*x*ss
+1.175*us*s-0.005*oq*u-0.270*ss*u+2.781*pr*s+0.058*x*u*s
-0.259*x*oq+0.352*x*pr+1.608*oq*s-0.189*pr*u;
}
newCorrelation = temp * correlation;
}
else if ( strcmp(typeRv1,"BETA") == 0 && (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) ) {
double ba = rv1Ptr->getParameter4() - rv1Ptr->getParameter3();
double u1 = ( rv1Ptr->getMean() - rv1Ptr->getParameter3() ) / ba;
double s1 = rv1Ptr->getStdv() / ba;
double temp = 1.055-0.066*correlation-0.194*u1+0.391*s1+0.003*correlation*correlation
+0.194*u1*u1-1.134*s1*s1+0.130*correlation*u1+0.003*correlation*s1;
newCorrelation = temp * correlation;
}
else if ( strcmp(typeRv1,"BETA") == 0 && strcmp(typeRv2,"TYPE1SMALLESTVALAUE") == 0 ) {
double ba = rv1Ptr->getParameter4() - rv1Ptr->getParameter3();
double u1 = ( rv1Ptr->getMean() - rv1Ptr->getParameter3() ) / ba;
double s1 = rv1Ptr->getStdv() / ba;
double temp = 1.055+0.066*correlation-0.194*u1+0.391*s1+0.003*correlation*correlation
+0.194*u1*u1-1.134*s1*s1-0.130*correlation*u1-0.003*correlation*s1;
newCorrelation = temp * correlation;
}
else if ( strcmp(typeRv1,"BETA") == 0 && strcmp(typeRv2,"TYPE2LARGESTVALUE") == 0 ) {
double ba1 = rv1Ptr->getParameter4() - rv1Ptr->getParameter3();
double u1 = ( rv1Ptr->getMean() - rv1Ptr->getParameter3() ) / ba1;
double s1 = rv1Ptr->getStdv() / ba1;
double uu=u1*u1;
double ss=s1*s1;
double xu=correlation*u1;
double xs=correlation*s1;
double us=u1*s1;
double uq=u1*cov2;
double sq=s1*cov2;
double xq=correlation*cov2;
double temp=1.005 + 0.091*correlation + 0.285*u1+ 0.260*s1+ 0.199*cov2
- 0.023*correlation*correlation - 0.285*uu + 8.180*ss + 0.543*cov2*cov2 - 0.181*xu
- 1.744*xs - 0.336*xq - 5.450*us - 0.265*uq + 0.514*sq
-19.661*ss*s1- 0.178*cov2*cov2*cov2
+ 0.244*correlation*xs + 0.066*correlation*correlation*cov2 - 0.001*correlation*ss
+ 5.450*uu*s1+ 0.265*uu*cov2 - 0.986*ss*cov2
+ 0.133*sq*cov2 + 3.488*correlation*us + 0.671*correlation*uq;
newCorrelation = temp * correlation;
}
else if ( strcmp(typeRv1,"BETA") == 0 && (strcmp(typeRv2,"TYPE3SMALLESTVALUE") == 0 || strcmp(typeRv2,"WEIBULL") == 0) ) {
double ba = rv1Ptr->getParameter4() - rv1Ptr->getParameter3();
double u1 = ( rv1Ptr->getMean() - rv1Ptr->getParameter3() ) / ba;
double s1 = rv1Ptr->getStdv() / ba;
double temp = 1.054+0.002*correlation-0.176*u1+0.366*s1-0.201*cov2
-0.002*correlation*correlation+0.176*u1*u1-1.098*s1*s1+0.340*cov2*cov2
-0.004*correlation*u1-0.029*s1*cov2;
newCorrelation = temp * correlation;
}
/////////////////////////////////////////////////////////////////////////////////
else if ( (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) && strcmp(typeRv2,"NORMAL") == 0 ) {
newCorrelation = 1.031 * correlation;
}
else if ( (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) && strcmp(typeRv2,"LOGNORMAL") == 0 ) {
newCorrelation = (1.029 + 0.001*correlation + 0.014*cov2 + 0.004*correlation*correlation
+ 0.233*cov2*cov2 - 0.197*correlation*cov2)*correlation;
}
else if ( (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) && strcmp(typeRv2,"GAMMA") == 0 ) {
newCorrelation = (1.031+0.001*correlation-0.007*cov2+0.003*correlation*correlation+0.131*cov2*cov2-0.132*correlation*cov2)*correlation;
}
else if ( (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) && (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) ) {
newCorrelation = (1.142-0.154*correlation+0.031*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) && (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) ) {
newCorrelation = (1.046-0.045*correlation+0.006*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) && strcmp(typeRv2,"UNIFORM") == 0 ) {
newCorrelation = (1.055+0.015*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) && strcmp(typeRv2,"BETA") == 0 ) {
double ba = rv2Ptr->getParameter4() - rv2Ptr->getParameter3();
double u2 = ( rv2Ptr->getMean() - rv2Ptr->getParameter3() ) / ba;
double s2 = rv2Ptr->getStdv() / ba;
double temp = 1.055-0.066*correlation-0.194*u2+0.391*s2+0.003*correlation*correlation
+0.194*u2*u2-1.134*s2*s2+0.130*correlation*u2+0.003*correlation*s2;
newCorrelation = temp * correlation;
}
else if ( (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) && (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) ) {
newCorrelation = (1.064-0.069*correlation+0.005*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) && strcmp(typeRv2,"TYPE1SMALLESTVALAUE") == 0 ) {
newCorrelation = (1.064+0.069*correlation+0.005*correlation*correlation)*correlation;
}
else if ( (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) && strcmp(typeRv2,"TYPE2LARGESTVALUE") == 0 ) {
newCorrelation = (1.056-0.060*correlation+0.263*cov2+0.020*correlation*correlation+0.383*cov2*cov2-0.332*correlation*cov1)*correlation;
}
else if ( (strcmp(typeRv2,"TYPE1LARGESTVALUE") == 0 || strcmp(typeRv2,"GUMBEL") == 0) && (strcmp(typeRv2,"TYPE3SMALLESTVALUE") == 0 || strcmp(typeRv2,"WEIBULL") == 0) ) {
newCorrelation = (1.064+0.065*correlation-0.210*cov2+0.003*correlation*correlation+0.356*cov2*cov2-0.211*correlation*cov2)*correlation;
}
/////////////////////////////////////////////////////////////////////////////////
else if ( strcmp(typeRv1,"TYPE1SMALLESTVALAUE") == 0 && strcmp(typeRv2,"NORMAL") == 0 ) {
newCorrelation = 1.031 * correlation;
}
else if ( strcmp(typeRv1,"TYPE1SMALLESTVALAUE") == 0 && strcmp(typeRv2,"LOGNORMAL") == 0 ) {
newCorrelation = (1.029 - 0.001*correlation + 0.014*cov2 + 0.004*correlation*correlation
+ 0.233*cov2*cov2 + 0.197*correlation*cov2) * correlation;
}
else if ( strcmp(typeRv1,"TYPE1SMALLESTVALAUE") == 0 && strcmp(typeRv2,"GAMMA") == 0 ) {
newCorrelation = (1.031-0.001*correlation-0.007*cov2+0.003*correlation*correlation+0.131*cov2*cov2+0.132*correlation*cov2)*correlation;
}
else if ( strcmp(typeRv1,"TYPE1SMALLESTVALAUE") == 0 && (strcmp(typeRv2,"EXPONENTIAL") == 0 || strcmp(typeRv2,"SHIFTEDEXPONENTIAL") == 0 ) ) {
newCorrelation = (1.142+0.154*correlation+0.031*correlation*correlation)*correlation;
}
else if ( strcmp(typeRv1,"TYPE1SMALLESTVALAUE") == 0 && (strcmp(typeRv2,"RAYLEIGH") == 0 || strcmp(typeRv2,"SHIFTEDRAYLEIGH") == 0 ) ) {
newCorrelation = (1.046+0.045*correlation+0.006*correlation*correlation)*correlation;
}
else if ( strcmp(typeRv1,"TYPE1SMALLESTVALAUE") == 0 && strcmp(typeRv2,"UNIFORM") == 0 ) {
newCorrelation = (1.055+0.015*correlation*correlation)*correlation;
}
else if ( strcmp(typeRv1,"TYPE1SMALLEST