EpetraExt Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpetraExt_ModelEvaluatorScalingTools.h
Go to the documentation of this file.
1 //@HEADER
2 // ***********************************************************************
3 //
4 // EpetraExt: Epetra Extended - Linear Algebra Services Package
5 // Copyright (2011) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 
42 #ifndef EPETRA_EXT_MODEL_EVALUATOR_SCALING_TOOLS_H
43 #define EPETRA_EXT_MODEL_EVALUATOR_SCALING_TOOLS_H
44 
45 #if defined(EpetraExt_SHOW_DEPRECATED_WARNINGS)
46 #ifdef __GNUC__
47 #warning "The EpetraExt package is deprecated"
48 #endif
49 #endif
50 
51 
53 #include "Teuchos_Utils.hpp"
54 
55 
56 namespace EpetraExt {
57 
58 
184 
185 
194  const ModelEvaluator &model,
195  ModelEvaluator::InArgs *nominalValues
196  );
197 
198 
206 void gatherModelBounds(
207  const ModelEvaluator &model,
208  ModelEvaluator::InArgs *lowerBounds,
209  ModelEvaluator::InArgs *upperBounds
210  );
211 
212 
247 void scaleModelVars(
248  const ModelEvaluator::InArgs &origVars,
249  const ModelEvaluator::InArgs &varScalings,
250  ModelEvaluator::InArgs *scaledVars,
251  Teuchos::FancyOStream *out = 0,
253  );
254 
259 void scaleModelBounds(
260  const ModelEvaluator::InArgs &origLowerBounds,
261  const ModelEvaluator::InArgs &origUpperBounds,
262  const double infBnd,
263  const ModelEvaluator::InArgs &varScalings,
264  ModelEvaluator::InArgs *scaledLowerBounds,
265  ModelEvaluator::InArgs *scaledUpperBounds,
266  Teuchos::FancyOStream *out = 0,
268  );
269 
270 
301 void unscaleModelVars(
302  const ModelEvaluator::InArgs &scaledVars,
303  const ModelEvaluator::InArgs &varScalings,
304  ModelEvaluator::InArgs *origVars,
305  Teuchos::FancyOStream *out = 0,
307  );
308 
309 
367 void scaleModelFuncs(
368  const ModelEvaluator::OutArgs &origFuncs,
369  const ModelEvaluator::InArgs &varScalings,
370  const ModelEvaluator::OutArgs &funcScalings,
371  ModelEvaluator::OutArgs *scaledFuncs,
372  bool *allFuncsWhereScaled,
373  Teuchos::FancyOStream *out = 0,
375  );
376 
377 
385  Teuchos::RCP<const Epetra_Vector> const& scalingVector
386  );
387 
388 
412  const Epetra_Vector &origVars,
413  const Epetra_Vector &invVarScaling,
414  Epetra_Vector *scaledVars
415  );
416 
417 
420  const Epetra_Vector &origLowerBounds,
421  const Epetra_Vector &origUpperBounds,
422  const double infBnd,
423  const Epetra_Vector &invVarScaling,
424  Epetra_Vector *scaledLowerBounds,
425  Epetra_Vector *scaledUpperBounds
426  );
427 
428 
452  const Epetra_Vector &origVars,
453  const Epetra_Vector &invVarScaling,
454  Epetra_Vector *scaledVars
455  );
456 
457 
477  const Epetra_Vector &fwdFuncScaling,
478  Epetra_Vector *funcs
479  );
480 
481 
511  const Epetra_Vector *invVarScaling,
512  const Epetra_Vector *fwdFuncScaling,
513  Epetra_Operator *funcDerivOp,
514  bool *didScaling
515  );
516 
517 
554  const ModelEvaluator::Derivative &origFuncDeriv,
555  const Epetra_Vector *invVarScaling,
556  const Epetra_Vector *fwdFuncScaling,
557  ModelEvaluator::Derivative *scaledFuncDeriv,
558  bool *didScaling
559  );
560 
561 
564 public:
565 
566  std::string getName() const { return "x_dot"; }
567 
569  getVector( const ModelEvaluator::InArgs &inArgs ) const
570  {
571  return inArgs.get_x_dot();
572  }
573 
574  void setVector(
576  ModelEvaluator::InArgs *inArgs
577  ) const
578  {
579 #ifdef TEUCHOS_DEBUG
580  TEUCHOS_TEST_FOR_EXCEPT(!inArgs);
581 #endif
582  inArgs->set_x_dot(x_dot);
583  }
584 
585 };
586 
587 
590 public:
591 
592  std::string getName() const { return "x_dotdot"; }
593 
595  getVector( const ModelEvaluator::InArgs &inArgs ) const
596  {
597  return inArgs.get_x_dotdot();
598  }
599 
600  void setVector(
601  const Teuchos::RCP<const Epetra_Vector> &x_dotdot,
602  ModelEvaluator::InArgs *inArgs
603  ) const
604  {
605 #ifdef TEUCHOS_DEBUG
606  TEUCHOS_TEST_FOR_EXCEPT(!inArgs);
607 #endif
608  inArgs->set_x_dotdot(x_dotdot);
609  }
610 
611 };
612 
613 
616 public:
617 
618  std::string getName() const { return "x"; }
619 
621  getVector( const ModelEvaluator::InArgs &inArgs ) const
622  {
623  return inArgs.get_x();
624  }
625 
626  void setVector(
628  ModelEvaluator::InArgs *inArgs
629  ) const
630  {
631 #ifdef TEUCHOS_DEBUG
632  TEUCHOS_TEST_FOR_EXCEPT(!inArgs);
633 #endif
634  inArgs->set_x(x);
635  }
636 
637 };
638 
639 
642 public:
643 
644  InArgsGetterSetter_p( int l ) : l_(l) {}
645 
646  std::string getName() const
647  { return "p["+Teuchos::Utils::toString(l_)+"]"; }
648 
650  getVector( const ModelEvaluator::InArgs &inArgs ) const
651  {
652  return inArgs.get_p(l_);
653  }
654 
655  void setVector(
657  ModelEvaluator::InArgs *inArgs
658  ) const
659  {
660 #ifdef TEUCHOS_DEBUG
661  TEUCHOS_TEST_FOR_EXCEPT(!inArgs);
662 #endif
663  inArgs->set_p(l_,p_l);
664  }
665 
666 private:
667 
668  int l_;
669 
670  InArgsGetterSetter_p(); // Not defined!
671 
672 };
673 
674 
677 public:
678 
680  getVector( const ModelEvaluator::OutArgs &outArgs ) const
681  {
682  return outArgs.get_f();
683  }
684 
685  void setVector(
687  ModelEvaluator::OutArgs *outArgs
688  ) const
689  {
690 #ifdef TEUCHOS_DEBUG
691  TEUCHOS_TEST_FOR_EXCEPT(!outArgs);
692 #endif
693  outArgs->set_f(f);
694  }
695 
696 };
697 
698 
701 public:
702 
703  OutArgsGetterSetter_g( int j ) : j_(j) {}
704 
706  getVector( const ModelEvaluator::OutArgs &outArgs ) const
707  {
708  return outArgs.get_g(j_);
709  }
710 
711  void setVector(
712  const Teuchos::RCP<Epetra_Vector> &g_j,
713  ModelEvaluator::OutArgs *outArgs
714  ) const
715  {
716 #ifdef TEUCHOS_DEBUG
717  TEUCHOS_TEST_FOR_EXCEPT(!outArgs);
718 #endif
719  outArgs->set_g(j_,g_j);
720  }
721 
722 private:
723 
724  int j_;
725 
726  OutArgsGetterSetter_g(); // Not defined!
727 
728 };
729 
730 
732 
733 
734 } // namespace EpetraExt
735 
736 
737 #endif // EPETRA_EXT_MODEL_EVALUATOR_SCALING_TOOLS_H
Teuchos::RCP< const Epetra_Vector > getVector(const ModelEvaluator::InArgs &inArgs) const
Class that gets and sets p(l) in an InArgs object.
void unscaleModelVarsGivenInverseScaling(const Epetra_Vector &origVars, const Epetra_Vector &invVarScaling, Epetra_Vector *scaledVars)
Unscale a vector given its inverse scaling vector.
void setVector(const Teuchos::RCP< Epetra_Vector > &g_j, ModelEvaluator::OutArgs *outArgs) const
void scaleModelFuncFirstDeriv(const ModelEvaluator::Derivative &origFuncDeriv, const Epetra_Vector *invVarScaling, const Epetra_Vector *fwdFuncScaling, ModelEvaluator::Derivative *scaledFuncDeriv, bool *didScaling)
Scale (in place) an output first-order function derivative object given its function and variable sca...
Evaluation< Epetra_Vector > get_g(int j) const
Get g(j) where 0 &lt;= j &amp;&amp; j &lt; this-&gt;Ng().
Teuchos::RCP< const Epetra_Vector > get_x_dotdot() const
void unscaleModelVars(const ModelEvaluator::InArgs &scaledVars, const ModelEvaluator::InArgs &varScalings, ModelEvaluator::InArgs *origVars, Teuchos::FancyOStream *out=0, Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_LOW)
Unscale the scaled variables.
void setVector(const Teuchos::RCP< const Epetra_Vector > &x_dotdot, ModelEvaluator::InArgs *inArgs) const
void set_x(const Teuchos::RCP< const Epetra_Vector > &x)
void set_x_dot(const Teuchos::RCP< const Epetra_Vector > &x_dot)
void scaleModelVarBoundsGivenInverseScaling(const Epetra_Vector &origLowerBounds, const Epetra_Vector &origUpperBounds, const double infBnd, const Epetra_Vector &invVarScaling, Epetra_Vector *scaledLowerBounds, Epetra_Vector *scaledUpperBounds)
Scale the model variable bounds.
void setVector(const Teuchos::RCP< Epetra_Vector > &f, ModelEvaluator::OutArgs *outArgs) const
void set_f(const Evaluation< Epetra_Vector > &f)
Class that gets and sets x_dotdot in an InArgs object.
Teuchos::RCP< const Epetra_Vector > get_p(int l) const
Class that gets and sets x_dot in an InArgs object.
void setVector(const Teuchos::RCP< const Epetra_Vector > &x, ModelEvaluator::InArgs *inArgs) const
static std::string toString(const double &x)
void set_x_dotdot(const Teuchos::RCP< const Epetra_Vector > &x_dotdot)
void scaleModelFuncFirstDerivOp(const Epetra_Vector *invVarScaling, const Epetra_Vector *fwdFuncScaling, Epetra_Operator *funcDerivOp, bool *didScaling)
Scale (in place) an output first-order function derivative object represented as an Epetra_Operator g...
void scaleModelFuncs(const ModelEvaluator::OutArgs &origFuncs, const ModelEvaluator::InArgs &varScalings, const ModelEvaluator::OutArgs &funcScalings, ModelEvaluator::OutArgs *scaledFuncs, bool *allFuncsWhereScaled, Teuchos::FancyOStream *out=0, Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_LOW)
Scale the output functions and their derivative objects.
void scaleModelFuncGivenForwardScaling(const Epetra_Vector &fwdFuncScaling, Epetra_Vector *funcs)
Scale (in place) an output function vector given its forward scaling vector.
Teuchos::RCP< const Epetra_Vector > getVector(const ModelEvaluator::InArgs &inArgs) const
void scaleModelVars(const ModelEvaluator::InArgs &origVars, const ModelEvaluator::InArgs &varScalings, ModelEvaluator::InArgs *scaledVars, Teuchos::FancyOStream *out=0, Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_LOW)
Scale the original unscaled variables into the scaled variables.
void set_p(int l, const Teuchos::RCP< const Epetra_Vector > &p_l)
Class that gets and sets f in an OutArgs object.
Teuchos::RCP< const Epetra_Vector > get_x_dot() const
Class that gets and sets g(j) in an OutArgs object.
Teuchos::RCP< const Epetra_Vector > createInverseModelScalingVector(Teuchos::RCP< const Epetra_Vector > const &scalingVector)
Create an inverse scaling vector.
Teuchos::RCP< Epetra_Vector > getVector(const ModelEvaluator::OutArgs &outArgs) const
Teuchos::RCP< Epetra_Vector > getVector(const ModelEvaluator::OutArgs &outArgs) const
void scaleModelVarsGivenInverseScaling(const Epetra_Vector &origVars, const Epetra_Vector &invVarScaling, Epetra_Vector *scaledVars)
Scale a vector given its inverse scaling vector.
void gatherModelBounds(const ModelEvaluator &model, ModelEvaluator::InArgs *lowerBounds, ModelEvaluator::InArgs *upperBounds)
Gather the lower and upper bounds from a model evaluator.
Class that gets and sets x in an InArgs object.
Teuchos::RCP< const Epetra_Vector > getVector(const ModelEvaluator::InArgs &inArgs) const
void scaleModelBounds(const ModelEvaluator::InArgs &origLowerBounds, const ModelEvaluator::InArgs &origUpperBounds, const double infBnd, const ModelEvaluator::InArgs &varScalings, ModelEvaluator::InArgs *scaledLowerBounds, ModelEvaluator::InArgs *scaledUpperBounds, Teuchos::FancyOStream *out=0, Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_LOW)
Scale the lower and upper model variable bounds.
Teuchos::RCP< const Epetra_Vector > getVector(const ModelEvaluator::InArgs &inArgs) const
void setVector(const Teuchos::RCP< const Epetra_Vector > &p_l, ModelEvaluator::InArgs *inArgs) const
void setVector(const Teuchos::RCP< const Epetra_Vector > &x_dot, ModelEvaluator::InArgs *inArgs) const
Evaluation< Epetra_Vector > get_f() const
void gatherModelNominalValues(const ModelEvaluator &model, ModelEvaluator::InArgs *nominalValues)
Gather the nominal values from a model evaluator.
Teuchos::RCP< const Epetra_Vector > get_x() const
Set solution vector Taylor polynomial.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
void set_g(int j, const Evaluation< Epetra_Vector > &g_j)
Set g(j) where 0 &lt;= j &amp;&amp; j &lt; this-&gt;Ng().