Subversion Repositories OpenSees

Rev

Rev 4801 | Rev 4803 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
291 mhscott 1
/* ****************************************************************** **
2
**    OpenSees - Open System for Earthquake Engineering Simulation    **
3
**          Pacific Earthquake Engineering Research Center            **
4
**                                                                    **
5
**                                                                    **
6
** (C) Copyright 2001, The Regents of the University of California    **
7
** All Rights Reserved.                                               **
8
**                                                                    **
9
** Commercial use of this program without express permission of the   **
10
** University of California, Berkeley, is strictly prohibited.  See   **
11
** file 'COPYRIGHT'  in main directory for information on usage and   **
12
** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
13
**                                                                    **
14
** Developed by:                                                      **
15
**   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
16
**   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
17
**   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
18
**                                                                    **
19
** Reliability module developed by:                                   **
20
**   Terje Haukaas (haukaas@ce.berkeley.edu)                          **
21
**   Armen Der Kiureghian (adk@ce.berkeley.edu)                       **
22
**                                                                    **
23
** ****************************************************************** */
24
 
4323 mhscott 25
// $Revision: 1.20 $
26
// $Date: 2010-09-13 21:34:43 $
291 mhscott 27
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/designPoint/SearchWithStepSizeAndStepDirection.cpp,v $
28
 
29
 
30
//
1334 fmk 31
// Written by Terje Haukaas (haukaas@ce.berkeley.edu) 
291 mhscott 32
//
33
 
34
#include <SearchWithStepSizeAndStepDirection.h>
1334 fmk 35
#include <FindDesignPointAlgorithm.h>
3498 mhscott 36
#include <ReliabilityDomain.h>
291 mhscott 37
#include <StepSizeRule.h>
38
#include <SearchDirection.h>
1334 fmk 39
#include <ProbabilityTransformation.h>
40
#include <NatafProbabilityTransformation.h>
4721 mhscott 41
#include <LimitStateFunction.h>
42
#include <FunctionEvaluator.h>
43
#include <GradientEvaluator.h>
291 mhscott 44
#include <RandomVariable.h>
4782 mackie 45
#include <RandomVariableIter.h>
291 mhscott 46
#include <CorrelationCoefficient.h>
47
#include <MatrixOperations.h>
1334 fmk 48
#include <HessianApproximation.h>
49
#include <ReliabilityConvergenceCheck.h>
291 mhscott 50
#include <Matrix.h>
51
#include <Vector.h>
52
 
1334 fmk 53
#include <fstream>
54
#include <iomanip>
55
#include <iostream>
4638 fmk 56
#include <math.h>
291 mhscott 57
 
1334 fmk 58
using std::ifstream;
59
using std::ios;
60
using std::setw;
61
using std::setprecision;
62
 
63
 
291 mhscott 64
SearchWithStepSizeAndStepDirection::SearchWithStepSizeAndStepDirection(
3498 mhscott 65
                                        int passedMaxNumberOfIterations,
66
                                        ReliabilityDomain *passedReliabilityDomain,
4782 mackie 67
                    Domain *passedOpenSeesDomain,
4721 mhscott 68
                                        FunctionEvaluator *passedFunctionEvaluator,
69
                                        GradientEvaluator *passedGradientEvaluator,
291 mhscott 70
                                        StepSizeRule *passedStepSizeRule,
71
                                        SearchDirection *passedSearchDirection,
1334 fmk 72
                                        ProbabilityTransformation *passedProbabilityTransformation,
73
                                        HessianApproximation *passedHessianApproximation,
74
                                        ReliabilityConvergenceCheck *passedReliabilityConvergenceCheck,
3659 mhscott 75
                                        bool pStartAtOrigin,
1334 fmk 76
                                        int pprintFlag,
3659 mhscott 77
                                        char *pFileNamePrint)
4782 mackie 78
  :FindDesignPointAlgorithm(), theReliabilityDomain(passedReliabilityDomain),
79
        theOpenSeesDomain(passedOpenSeesDomain)
291 mhscott 80
{
81
        maxNumberOfIterations                   = passedMaxNumberOfIterations;
4721 mhscott 82
        theFunctionEvaluator                            = passedFunctionEvaluator;
83
        theGradientEvaluator                            = passedGradientEvaluator;
291 mhscott 84
        theStepSizeRule                                 = passedStepSizeRule;
85
        theSearchDirection                              = passedSearchDirection;
1334 fmk 86
        theProbabilityTransformation    = passedProbabilityTransformation;
87
        theHessianApproximation                 = passedHessianApproximation;
88
        theReliabilityConvergenceCheck  = passedReliabilityConvergenceCheck;
3659 mhscott 89
        //startPoint                                            = pStartPoint;
90
        startAtOrigin = pStartAtOrigin;
1334 fmk 91
        printFlag                                               = pprintFlag;
4802 mackie 92
        numberOfEvaluations = 0;
1334 fmk 93
        if (printFlag != 0) {
94
                strcpy(fileNamePrint,pFileNamePrint);
95
        }
3498 mhscott 96
 
4721 mhscott 97
        int nrv = theReliabilityDomain->getNumberOfRandomVariables();
3498 mhscott 98
        x = new Vector(nrv);
99
        u = new Vector(nrv);
100
        alpha = new Vector(nrv);
101
        gamma = new Vector(nrv);
102
        gradientInStandardNormalSpace = new Vector(nrv);
103
        uSecondLast = new Vector(nrv);
104
        alphaSecondLast = new Vector(nrv);
105
        searchDirection = new Vector(nrv);
291 mhscott 106
}
107
 
108
 
109
 
110
SearchWithStepSizeAndStepDirection::~SearchWithStepSizeAndStepDirection()
111
{
3498 mhscott 112
        if (x != 0)
113
                delete x;
114
        if (u != 0)
115
                delete u;
116
        if (alpha != 0)
117
                delete alpha;
118
        if (gamma != 0)
119
                delete gamma;
120
        if (gradientInStandardNormalSpace != 0)
121
                delete gradientInStandardNormalSpace;
122
        if (uSecondLast != 0)
123
                delete uSecondLast;
124
        if (alphaSecondLast != 0)
125
                delete alphaSecondLast;
126
    if (searchDirection != 0)
127
                delete searchDirection;
128
 
291 mhscott 129
}
130
 
131
 
132
int
3498 mhscott 133
SearchWithStepSizeAndStepDirection::findDesignPoint()
291 mhscott 134
{
135
 
1334 fmk 136
        // Declaration of data used in the algorithm
291 mhscott 137
        int numberOfRandomVariables = theReliabilityDomain->getNumberOfRandomVariables();
4784 mackie 138
    int numberOfParameters = theOpenSeesDomain->getNumParameters();
139
        int zeroFlag, result;
3498 mhscott 140
        int evaluationInStepSize = 0;
141
 
1334 fmk 142
        double gFunctionValue = 1.0;
143
        double gFunctionValue_old = 1.0;
3498 mhscott 144
        double normOfGradient = 0.0;
145
        double stepSize = 1.0;
146
 
147
        Vector u_old(numberOfRandomVariables);
148
        Vector uNew(numberOfRandomVariables);  
291 mhscott 149
        Vector gradientOfgFunction(numberOfRandomVariables);
1334 fmk 150
        Vector gradientInStandardNormalSpace_old(numberOfRandomVariables);
3498 mhscott 151
 
4782 mackie 152
    Matrix Jxu(numberOfRandomVariables, numberOfRandomVariables);
153
        Matrix Jux(numberOfRandomVariables, numberOfRandomVariables);
3498 mhscott 154
 
4721 mhscott 155
        theFunctionEvaluator->initializeNumberOfEvaluations();
291 mhscott 156
 
1334 fmk 157
        // Prepare output file to store the search points
4721 mhscott 158
        /*
159
        if (printFlag != 0)
160
                ofstream outputFile2( fileNamePrint, ios::out );
161
        */
291 mhscott 162
 
3659 mhscott 163
        // Get starting point
4782 mackie 164
    // KRM this is now taken care of elsewhere, the values of start point are set within the parameters themselves
165
        /*if (startAtOrigin)
4721 mhscott 166
                u->Zero();
1334 fmk 167
        else {
4721 mhscott 168
                //theReliabilityDomain->getStartPoint(*x);
169
                for (int j = 0; j < numberOfRandomVariables; j++) {
170
                        RandomVariable *theParam = theReliabilityDomain->getRandomVariablePtrFromIndex(j);
171
                        (*x)(j) = theParam->getStartValue();
4782 mackie 172
 
173
            // KRM now we need to make a call to setParamter with this value or just use the existing
174
            // value stored in the parameter
4721 mhscott 175
                }
291 mhscott 176
 
4721 mhscott 177
                // Transform starting point into standard normal space
4782 mackie 178
                result = theProbabilityTransformation->transform_x_to_u(*u);
4721 mhscott 179
                if (result < 0) {
180
                        opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
181
                           << " could not transform from x to u." << endln;
182
                        return -1;
3659 mhscott 183
          }
291 mhscott 184
        }
4782 mackie 185
     */
186
 
187
    // get starting x values from parameter directly
188
    for (int j = 0; j < numberOfRandomVariables; j++) {
189
        RandomVariable *theParam = theReliabilityDomain->getRandomVariablePtrFromIndex(j);
4784 mackie 190
        double rvVal = theParam->getStartValue();
191
        (*x)(j) = rvVal;
192
 
193
        // now we should update the parameter value 
194
        // KRM should this be a parameter reference now?
195
        theParam->setCurrentValue(rvVal);
4782 mackie 196
    }
4792 mhscott 197
 
4782 mackie 198
    // Transform starting point into standard normal space to initialize u vector
199
    result = theProbabilityTransformation->transform_x_to_u(*u);
200
    if (result < 0) {
201
        opserr << "SearchWithStepSizeAndStepDirection::findDesignPoint() - " << endln
202
               << " could not transform from x to u." << endln;
203
        return -1;
204
    }
291 mhscott 205
 
206
        // Loop to find design point
3498 mhscott 207
        steps = 1;
208
        while ( steps <= maxNumberOfIterations )
291 mhscott 209
        {
210
 
510 mhscott 211
                // Evaluate limit-state function unless it has been done in 
212
                // a trial step by the "stepSizeAlgorithm"
1334 fmk 213
                if (evaluationInStepSize == 0) {
4721 mhscott 214
                        // set perturbed values in the variable namespace
215
                        if (theFunctionEvaluator->setVariables(*x) < 0) {
216
                                opserr << "ERROR SearchWithStepSizeAndStepDirection -- error setting variables in namespace" << endln;
510 mhscott 217
                                return -1;
218
                        }
4721 mhscott 219
 
220
                        // run analysis
221
                        if (theFunctionEvaluator->runAnalysis(*x) < 0) {
222
                                opserr << "ERROR SearchWithStepSizeAndStepDirection -- error running analysis" << endln;
1334 fmk 223
                                return -1;
224
                        }
4721 mhscott 225
 
226
                        // evaluate LSF and obtain result
227
                        int lsfTag = theReliabilityDomain->getTagOfActiveLimitStateFunction();
228
                        LimitStateFunction *theLimitStateFunction = theReliabilityDomain->getLimitStateFunctionPtr(lsfTag);
229
                        const char *lsfExpression = theLimitStateFunction->getExpression();
230
                        theFunctionEvaluator->setExpression(lsfExpression);
231
 
1334 fmk 232
                        gFunctionValue_old = gFunctionValue;
4801 mackie 233
                        gFunctionValue = theFunctionEvaluator->evaluateExpression();
4721 mhscott 234
 
291 mhscott 235
                }
236
 
1334 fmk 237
                // Set scale parameter
3498 mhscott 238
                if (steps == 1) {
1334 fmk 239
                        Gfirst = gFunctionValue;
4323 mhscott 240
                        if (printFlag != 0) {
241
                          opserr << " Limit-state function value at start point, g=" << gFunctionValue << endln;
242
                          opserr << " STEP #0: ";
243
                        }
1592 mhscott 244
                        theReliabilityConvergenceCheck->setScaleValue(gFunctionValue);
510 mhscott 245
                }
246
 
247
 
291 mhscott 248
                // Gradient in original space
4782 mackie 249
                result = theGradientEvaluator->computeGradient(gFunctionValue);
1592 mhscott 250
                if (result < 0) {
251
                        opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
252
                                << " could not compute gradients of the limit-state function. " << endln;
253
                        return -1;
254
                }
4721 mhscott 255
                gradientOfgFunction = theGradientEvaluator->getGradient();
291 mhscott 256
 
4782 mackie 257
                // Check if all components of the vector are zero
4721 mhscott 258
                if (gradientOfgFunction.Norm() == 0.0) {
1592 mhscott 259
                        opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
260
                                << " all components of the gradient vector is zero. " << endln;
261
                        return -1;
262
                }
4782 mackie 263
 
264
                // Get Jacobian x-space to u-space
265
                result = theProbabilityTransformation->getJacobian_x_to_u(Jxu);
266
                if (result < 0) {
267
            opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
268
            << " could not transform Jacobian from x to u." << endln;
269
            return -1;
270
                }
291 mhscott 271
 
1592 mhscott 272
                // Gradient in standard normal space
3498 mhscott 273
                gradientInStandardNormalSpace_old = *gradientInStandardNormalSpace;
2787 mhscott 274
                //gradientInStandardNormalSpace = jacobian_x_u ^ gradientOfgFunction;
3212 mhscott 275
                //gradientInStandardNormalSpace.addMatrixTransposeVector(0.0, jacobian_x_u, gradientOfgFunction, 1.0);
3498 mhscott 276
                gradientInStandardNormalSpace->addMatrixTransposeVector(0.0, Jxu, gradientOfgFunction, 1.0);
291 mhscott 277
 
278
 
279
                // Compute the norm of the gradient in standard normal space
3498 mhscott 280
                normOfGradient = gradientInStandardNormalSpace->Norm();
291 mhscott 281
 
282
 
283
                // Check that the norm is not zero
284
                if (normOfGradient == 0.0) {
1271 fmk 285
                        opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
286
                                << " the norm of the gradient is zero. " << endln;
291 mhscott 287
                        return -1;
288
                }
289
 
3606 mhscott 290
                // check there are no sucessive large betas
291
                int earlyexit = 0;
292
                if ( u->Norm() > uSecondLast->Norm() > 10 )
293
                        earlyexit = 1;
1334 fmk 294
 
291 mhscott 295
                // Compute alpha-vector
3498 mhscott 296
                alpha->addVector(0.0, *gradientInStandardNormalSpace, -1.0/normOfGradient );
291 mhscott 297
 
298
 
299
                // Check convergence
3498 mhscott 300
                result = theReliabilityConvergenceCheck->check(*u,gFunctionValue,*gradientInStandardNormalSpace);
4782 mackie 301
 
3498 mhscott 302
                if (result > 0 || steps == maxNumberOfIterations)  {
1334 fmk 303
 
304
                        // Inform the user of the happy news!
1592 mhscott 305
                        opserr << "Design point found!" << endln;
510 mhscott 306
 
4721 mhscott 307
                        /*
1334 fmk 308
                        // Print the design point to file, if desired
309
                        int iii;
310
                        if (printFlag != 0) {
311
                                if (printFlag == 3) {
312
                                        result = theProbabilityTransformation->set_u(u);
313
                                        if (result < 0) {
314
                                                opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
315
                                                        << " could not set u in the xu-transformation." << endln;
316
                                                return -1;
317
                                        }
318
 
319
                                        result = theProbabilityTransformation->transform_u_to_x();
320
                                        if (result < 0) {
321
                                                opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
322
                                                        << " could not transform from u to x." << endln;
323
                                                return -1;
324
                                        }
325
                                        x = theProbabilityTransformation->get_x();
4721 mhscott 326
 
3498 mhscott 327
                                  result = theProbabilityTransformation->transform_u_to_x(*u, *x);
3212 mhscott 328
                                  if (result < 0) {
329
                                    opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
330
                                           << " could not transform from u to x." << endln;
331
                                    return -1;
332
                                  }
1334 fmk 333
 
334
                                        outputFile2.setf(ios::scientific, ios::floatfield);
3498 mhscott 335
                                        for (iii=0; iii<x->Size(); iii++) {
336
                                                outputFile2<<setprecision(5)<<setw(15)<<(*x)(iii)<<endln;
1334 fmk 337
                                        }
338
                                }
339
                                else if (printFlag == 4) {
340
                                        static ofstream outputFile2( fileNamePrint, ios::out );
341
                                        outputFile2.setf(ios::scientific, ios::floatfield);
3498 mhscott 342
                                        for (iii=0; iii<u->Size(); iii++) {
343
                                                outputFile2<<setprecision(5)<<setw(15)<<(*u)(iii)<<endln;
1334 fmk 344
                                        }
345
                                }
346
                        }
4721 mhscott 347
                        */
1334 fmk 348
 
349
 
510 mhscott 350
                        // Compute the gamma vector
3212 mhscott 351
                        // Get Jacobian u-space to x-space
3498 mhscott 352
                        result = theProbabilityTransformation->getJacobian_u_to_x(*u, Jux);
3212 mhscott 353
                        if (result < 0) {
354
                          opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
355
                                 << " could not transform from u to x." << endln;
356
                          return -1;
357
                        }
291 mhscott 358
 
2787 mhscott 359
                        //Vector tempProduct = jacobian_u_x ^ alpha;
360
                        Vector tempProduct(numberOfRandomVariables);
3212 mhscott 361
                        //tempProduct.addMatrixTransposeVector(0.0, jacobian_u_x, alpha, 1.0);
3498 mhscott 362
                        tempProduct.addMatrixTransposeVector(0.0, Jux, *alpha, 1.0);
291 mhscott 363
 
2987 mhscott 364
                        // Only diagonal elements of (J_xu*J_xu^T) are used
4784 mackie 365
                        for (int j = 0; j < numberOfRandomVariables; j++) {
2987 mhscott 366
                          double sum = 0.0;
367
                          double jk;
368
                          for (int k = 0; k < numberOfRandomVariables; k++) {
3212 mhscott 369
                            //jk = jacobian_x_u(j,k);
370
                            jk = Jxu(j,k);
2987 mhscott 371
                            sum += jk*jk;
372
                          }
3498 mhscott 373
                          (*gamma)(j) = sqrt(sum) * tempProduct(j);
2987 mhscott 374
                        }
1334 fmk 375
 
376
                        Glast = gFunctionValue;
291 mhscott 377
 
4721 mhscott 378
                        numberOfEvaluations = theFunctionEvaluator->getNumberOfEvaluations();
3521 mhscott 379
 
380
                        // compute sensitivity pf beta wrt to LSF parameters (if they exist)
4721 mhscott 381
                        // Note this will need to change because now parameters have multiple derived classes
382
                        /*
383
                        const Matrix &dGdPar = theGradientEvaluator->getDgDpar();
3521 mhscott 384
                        int numPars = dGdPar.noRows();
385
                        if (numPars > 0 && dGdPar.noCols() > 1) {
386
                                opserr << "Sensitivity of beta wrt LSF parameters: ";
387
                                Vector dBetadPar(numPars);
388
 
389
                                for (int ib=0; ib<numPars; ib++)
390
                                        dBetadPar(ib) = dGdPar(ib,1) / gradientInStandardNormalSpace->Norm();
391
 
392
                                opserr << dBetadPar;
393
                        }
4721 mhscott 394
                        */
291 mhscott 395
                        return 1;
396
                }
397
 
398
 
399
                // Store 'u' and 'alpha' at the second last iteration point
3498 mhscott 400
                *uSecondLast = *u;
401
                *alphaSecondLast = *alpha;
291 mhscott 402
 
403
 
1334 fmk 404
                // Let user know that we have to take a new step
4323 mhscott 405
                if (printFlag != 0)
406
                  opserr << " STEP #" << steps <<": ";
1334 fmk 407
 
408
 
4792 mhscott 409
 
1334 fmk 410
                // Update Hessian approximation, if any
3498 mhscott 411
                if (  (theHessianApproximation!=0) && (steps!=1)  ) {
1334 fmk 412
                        theHessianApproximation->updateHessianApproximation(u_old,
413
                                                                                            gFunctionValue_old,
414
                                                                                            gradientInStandardNormalSpace_old,
415
                                                                                            stepSize,
3498 mhscott 416
                                                                                            *searchDirection,
1334 fmk 417
                                                                                            gFunctionValue,
3498 mhscott 418
                                                                                            *gradientInStandardNormalSpace);
1334 fmk 419
                }
420
 
421
 
291 mhscott 422
                // Determine search direction
3498 mhscott 423
                result = theSearchDirection->computeSearchDirection(steps,
424
                        *u, gFunctionValue, *gradientInStandardNormalSpace );
291 mhscott 425
                if (result < 0) {
1271 fmk 426
                        opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
427
                                << " could not compute search direction. " << endln;
291 mhscott 428
                        return -1;
429
                }
3498 mhscott 430
                *searchDirection = theSearchDirection->getSearchDirection();
291 mhscott 431
 
432
 
4792 mhscott 433
 
291 mhscott 434
                // Determine step size
435
                result = theStepSizeRule->computeStepSize(
3498 mhscott 436
                        *u, *gradientInStandardNormalSpace, gFunctionValue, *searchDirection, steps);
4802 mackie 437
                if (result < 0) {  
438
            // something went wrong
1271 fmk 439
                        opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
440
                                << " could not compute step size. " << endln;
291 mhscott 441
                        return -1;
442
                }
4802 mackie 443
                else if (result == 0) {  
444
            // nothing was evaluated in step size
1334 fmk 445
                        evaluationInStepSize = 0;
446
                }
4802 mackie 447
                else if (result == 1) {  
448
            // the gfun was evaluated
1334 fmk 449
                        evaluationInStepSize = 1;
450
                        gFunctionValue_old = gFunctionValue;
451
                        gFunctionValue = theStepSizeRule->getGFunValue();
452
                }
291 mhscott 453
                stepSize = theStepSizeRule->getStepSize();
454
 
455
 
3606 mhscott 456
                // save the previous displacement before modifying
3498 mhscott 457
                u_old = *u;
3606 mhscott 458
                double udiff = 20.0;
459
                double stepSizeMod = 1.0;
460
 
461
                // Determine new iteration point (take the step), BUT limit the maximum jump that can occur
462
                while ( fabs(udiff) > 15 ) {
463
                        *u = u_old;
464
 
4323 mhscott 465
                        if (stepSizeMod < 1 && printFlag != 0)
466
                          opserr << "SearchWithStepSizeAndStepDirection:: reducing stepSize using modification factor of " << stepSizeMod << endln;
510 mhscott 467
 
3606 mhscott 468
                        //u = u_old + (searchDirection * stepSize);
469
                        u->addVector(1.0, *searchDirection, stepSize*stepSizeMod);
510 mhscott 470
 
3606 mhscott 471
                        udiff = u->Norm() - u_old.Norm();
472
                        stepSizeMod *= 0.75;
473
                }
4782 mackie 474
 
475
        // Transform to x-space
476
                result = theProbabilityTransformation->transform_u_to_x(*u, *x);
477
                if (result < 0) {
478
            opserr << "SearchWithStepSizeAndStepDirection::doTheActualSearch() - " << endln
479
            << " could not transform from u to x." << endln;
480
            return -1;
481
                }
482
 
483
        // update domain with new x values
484
        RandomVariable *theRV;
485
        RandomVariableIter &rvIter = theReliabilityDomain->getRandomVariables();
486
        //for ( int i=0 ; i<nrv ; i++ ) {
487
        while ((theRV = rvIter()) != 0) {
488
            int rvTag = theRV->getTag();
489
            //int i = theRV->getIndex();
490
            int i = theReliabilityDomain->getRandomVariableIndex(rvTag);
491
            theRV->setCurrentValue( (*x)(i) );
492
        }
3606 mhscott 493
 
291 mhscott 494
                // Increment the loop parameter
3498 mhscott 495
                steps++;
291 mhscott 496
 
497
        }
498
 
499
 
500
        // Print a message if max number of iterations was reached
1334 fmk 501
        // (Note: in this case the last trial point was never transformed/printed)
1271 fmk 502
        opserr << "Maximum number of iterations was reached before convergence." << endln;
1334 fmk 503
 
4721 mhscott 504
        /*
505
        if (printFlag != 0)
506
                outputFile2.close();
507
        */
508
 
1334 fmk 509
        return -1;
291 mhscott 510
}
511
 
512
 
513
 
2736 mhscott 514
const Vector&
291 mhscott 515
SearchWithStepSizeAndStepDirection::get_x()
516
{
3498 mhscott 517
        return *x;
291 mhscott 518
}
519
 
2736 mhscott 520
const Vector &
291 mhscott 521
SearchWithStepSizeAndStepDirection::get_u()
522
{
3498 mhscott 523
        return *u;
291 mhscott 524
}
525
 
2736 mhscott 526
const Vector&
291 mhscott 527
SearchWithStepSizeAndStepDirection::get_alpha()
528
{
3498 mhscott 529
        return *alpha;
291 mhscott 530
}
531
 
2736 mhscott 532
const Vector&
291 mhscott 533
SearchWithStepSizeAndStepDirection::get_gamma()
534
{
3498 mhscott 535
  if (gamma->Norm() > 1.0)
536
    gamma->Normalize();
2736 mhscott 537
 
3498 mhscott 538
  return *gamma;
291 mhscott 539
}
540
 
541
int
1334 fmk 542
SearchWithStepSizeAndStepDirection::getNumberOfSteps()
291 mhscott 543
{
3498 mhscott 544
        return (steps-1);
291 mhscott 545
}
546
 
2736 mhscott 547
const Vector&
291 mhscott 548
SearchWithStepSizeAndStepDirection::getSecondLast_u()
549
{
3498 mhscott 550
        return *uSecondLast;
291 mhscott 551
}
552
 
2736 mhscott 553
const Vector&
291 mhscott 554
SearchWithStepSizeAndStepDirection::getSecondLast_alpha()
555
{
3498 mhscott 556
        return *alphaSecondLast;
291 mhscott 557
}
558
 
2736 mhscott 559
const Vector&
291 mhscott 560
SearchWithStepSizeAndStepDirection::getLastSearchDirection()
561
{
3498 mhscott 562
        return *searchDirection;
291 mhscott 563
}
564
 
565
double
566
SearchWithStepSizeAndStepDirection::getFirstGFunValue()
567
{
1334 fmk 568
        return Gfirst;
291 mhscott 569
}
570
 
1334 fmk 571
double
572
SearchWithStepSizeAndStepDirection::getLastGFunValue()
573
{
574
        return Glast;
575
}
291 mhscott 576
 
577
 
2736 mhscott 578
const Vector&
1334 fmk 579
SearchWithStepSizeAndStepDirection::getGradientInStandardNormalSpace()
580
{
3498 mhscott 581
        return *gradientInStandardNormalSpace;
1334 fmk 582
}
291 mhscott 583
 
584
 
585
 
1592 mhscott 586
int
587
SearchWithStepSizeAndStepDirection::getNumberOfEvaluations()
588
{
589
        return numberOfEvaluations;
590
}
1334 fmk 591
 
592
 
3358 fmk 593
// Quan and Michele
594
int SearchWithStepSizeAndStepDirection::setStartPt(Vector * pStartPt)
595
{
3659 mhscott 596
  //startPoint->addVector(0.0,(*pStartPt),1.0);
3358 fmk 597
        return 0;
598
}
1592 mhscott 599
 
600