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 
47 #include "Teuchos_Utils.hpp"
48 
49 
50 namespace EpetraExt {
51 
52 
178 
179 
188  const ModelEvaluator &model,
189  ModelEvaluator::InArgs *nominalValues
190  );
191 
192 
200 void gatherModelBounds(
201  const ModelEvaluator &model,
202  ModelEvaluator::InArgs *lowerBounds,
203  ModelEvaluator::InArgs *upperBounds
204  );
205 
206 
241 void scaleModelVars(
242  const ModelEvaluator::InArgs &origVars,
243  const ModelEvaluator::InArgs &varScalings,
244  ModelEvaluator::InArgs *scaledVars,
245  Teuchos::FancyOStream *out = 0,
247  );
248 
253 void scaleModelBounds(
254  const ModelEvaluator::InArgs &origLowerBounds,
255  const ModelEvaluator::InArgs &origUpperBounds,
256  const double infBnd,
257  const ModelEvaluator::InArgs &varScalings,
258  ModelEvaluator::InArgs *scaledLowerBounds,
259  ModelEvaluator::InArgs *scaledUpperBounds,
260  Teuchos::FancyOStream *out = 0,
262  );
263 
264 
295 void unscaleModelVars(
296  const ModelEvaluator::InArgs &scaledVars,
297  const ModelEvaluator::InArgs &varScalings,
298  ModelEvaluator::InArgs *origVars,
299  Teuchos::FancyOStream *out = 0,
301  );
302 
303 
361 void scaleModelFuncs(
362  const ModelEvaluator::OutArgs &origFuncs,
363  const ModelEvaluator::InArgs &varScalings,
364  const ModelEvaluator::OutArgs &funcScalings,
365  ModelEvaluator::OutArgs *scaledFuncs,
366  bool *allFuncsWhereScaled,
367  Teuchos::FancyOStream *out = 0,
369  );
370 
371 
379  Teuchos::RCP<const Epetra_Vector> const& scalingVector
380  );
381 
382 
406  const Epetra_Vector &origVars,
407  const Epetra_Vector &invVarScaling,
408  Epetra_Vector *scaledVars
409  );
410 
411 
414  const Epetra_Vector &origLowerBounds,
415  const Epetra_Vector &origUpperBounds,
416  const double infBnd,
417  const Epetra_Vector &invVarScaling,
418  Epetra_Vector *scaledLowerBounds,
419  Epetra_Vector *scaledUpperBounds
420  );
421 
422 
446  const Epetra_Vector &origVars,
447  const Epetra_Vector &invVarScaling,
448  Epetra_Vector *scaledVars
449  );
450 
451 
471  const Epetra_Vector &fwdFuncScaling,
472  Epetra_Vector *funcs
473  );
474 
475 
505  const Epetra_Vector *invVarScaling,
506  const Epetra_Vector *fwdFuncScaling,
507  Epetra_Operator *funcDerivOp,
508  bool *didScaling
509  );
510 
511 
548  const ModelEvaluator::Derivative &origFuncDeriv,
549  const Epetra_Vector *invVarScaling,
550  const Epetra_Vector *fwdFuncScaling,
551  ModelEvaluator::Derivative *scaledFuncDeriv,
552  bool *didScaling
553  );
554 
555 
558 public:
559 
560  std::string getName() const { return "x_dot"; }
561 
563  getVector( const ModelEvaluator::InArgs &inArgs ) const
564  {
565  return inArgs.get_x_dot();
566  }
567 
568  void setVector(
570  ModelEvaluator::InArgs *inArgs
571  ) const
572  {
573 #ifdef TEUCHOS_DEBUG
574  TEUCHOS_TEST_FOR_EXCEPT(!inArgs);
575 #endif
576  inArgs->set_x_dot(x_dot);
577  }
578 
579 };
580 
581 
584 public:
585 
586  std::string getName() const { return "x_dotdot"; }
587 
589  getVector( const ModelEvaluator::InArgs &inArgs ) const
590  {
591  return inArgs.get_x_dotdot();
592  }
593 
594  void setVector(
595  const Teuchos::RCP<const Epetra_Vector> &x_dotdot,
596  ModelEvaluator::InArgs *inArgs
597  ) const
598  {
599 #ifdef TEUCHOS_DEBUG
600  TEUCHOS_TEST_FOR_EXCEPT(!inArgs);
601 #endif
602  inArgs->set_x_dotdot(x_dotdot);
603  }
604 
605 };
606 
607 
610 public:
611 
612  std::string getName() const { return "x"; }
613 
615  getVector( const ModelEvaluator::InArgs &inArgs ) const
616  {
617  return inArgs.get_x();
618  }
619 
620  void setVector(
622  ModelEvaluator::InArgs *inArgs
623  ) const
624  {
625 #ifdef TEUCHOS_DEBUG
626  TEUCHOS_TEST_FOR_EXCEPT(!inArgs);
627 #endif
628  inArgs->set_x(x);
629  }
630 
631 };
632 
633 
636 public:
637 
638  InArgsGetterSetter_p( int l ) : l_(l) {}
639 
640  std::string getName() const
641  { return "p["+Teuchos::Utils::toString(l_)+"]"; }
642 
644  getVector( const ModelEvaluator::InArgs &inArgs ) const
645  {
646  return inArgs.get_p(l_);
647  }
648 
649  void setVector(
651  ModelEvaluator::InArgs *inArgs
652  ) const
653  {
654 #ifdef TEUCHOS_DEBUG
655  TEUCHOS_TEST_FOR_EXCEPT(!inArgs);
656 #endif
657  inArgs->set_p(l_,p_l);
658  }
659 
660 private:
661 
662  int l_;
663 
664  InArgsGetterSetter_p(); // Not defined!
665 
666 };
667 
668 
671 public:
672 
674  getVector( const ModelEvaluator::OutArgs &outArgs ) const
675  {
676  return outArgs.get_f();
677  }
678 
679  void setVector(
681  ModelEvaluator::OutArgs *outArgs
682  ) const
683  {
684 #ifdef TEUCHOS_DEBUG
685  TEUCHOS_TEST_FOR_EXCEPT(!outArgs);
686 #endif
687  outArgs->set_f(f);
688  }
689 
690 };
691 
692 
695 public:
696 
697  OutArgsGetterSetter_g( int j ) : j_(j) {}
698 
700  getVector( const ModelEvaluator::OutArgs &outArgs ) const
701  {
702  return outArgs.get_g(j_);
703  }
704 
705  void setVector(
706  const Teuchos::RCP<Epetra_Vector> &g_j,
707  ModelEvaluator::OutArgs *outArgs
708  ) const
709  {
710 #ifdef TEUCHOS_DEBUG
711  TEUCHOS_TEST_FOR_EXCEPT(!outArgs);
712 #endif
713  outArgs->set_g(j_,g_j);
714  }
715 
716 private:
717 
718  int j_;
719 
720  OutArgsGetterSetter_g(); // Not defined!
721 
722 };
723 
724 
726 
727 
728 } // namespace EpetraExt
729 
730 
731 #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().