[Trilinos-Users] Moocho question.
Bartlett, Roscoe A
rabartl at sandia.gov
Tue Jun 10 11:09:30 MDT 2008
Luca,
If you look at the example EpetraExt::ModelEvaluator subclass at:
Trilinos/packages/epetraext/example/model_evaluator/4dopt/EpetraModelEval4DOpt.[hpp,cpp]
you will see how W=DfDx gets implemented as an Epetra_CrsMatix object (where you build an Epetra_CrsGraph object first). Right now, you have to at least form DfDx manually yourself. In the future (perhaps even by Trilinos 9.0), there may be code hooked up that will compute W=DfDx by colored finite differences. In this case, you can just implement the evaluations of f(x,p) and g(x,p) and that is it for small problems. For larger problems, you will have to provide an Epetra_CrsGraph for the structure of W=DfDx so that the colored finite-difference code can approximate this matrix in a scalable way. Be warned however, that using finite differences for derivatives can make problems very hard to solve to any accuracy if there is any ill-conditioning in the problem. The optimization algorithms run much better typically with analytical derivates like you get with automatic differentiation (see the Trilinos package Sacado for a good C++ AD implementation). We may have an example of using AD Sacado with MOOCHO in Trilinos 9.0 but I can't promise that.
Cheers,
- Ross
-----Original Message-----
From: Luca Heltai [mailto:luca.heltai at gmail.com]
Sent: Tuesday, June 10, 2008 10:57 AM
To: Bartlett, Roscoe A
Cc: trilinos-users at software.sandia.gov
Subject: Re: [Trilinos-Users] Moocho question.
Ross,
thanks a lot for the pointer! I got the examples working with finite differences, as well as another small custom example I wrote on my own, just to make sure things were the way I expected them to be...
Now the next question... Is it possible to eliminate the need to compute explicitly DfDx=W as well? I'm stuck in trying to find the correct interpretation for the
Teuchos::RCP<Thyra::LinearOpWithSolveFactoryBase<double> >
lowsFactory = lowsfCreator.createLinearSolveStrategy("");
object, which in the EpetraModelEvaluator documentation is also referred to as W_factory...
EpetraModelEvaluator(
const RCP<const EpetraExt::ModelEvaluator> &epetraModel,
const RCP<LinearOpWithSolveFactoryBase<double> > &W_factory
);
I'm trying to find a reasonable explanation for all these function calls and constructors, but I don't think I found my way in the documentation yet... Is there a good starting point to find out about these? Moocho is not very verbose about them, and EpetraExt isn't too talkative either...
Thanks in advance!
Luca
--
Luca Heltai <luca.heltai at gmail.com>
http://www-dimat.unipv.it/heltai
--
There are no answers, only cross references.
On 10/giu/08, at 16:31, Bartlett, Roscoe A wrote:
> Luca,
>
> To see the exact input that the executables are designed to run with,
> see:
>
> Trilinos/packages/moocho/test/definition
>
> There you will see the exact inputs that are tested. If you turn off
> derivative support in this example, you have to turn on finite
> differencing explicitly. The above moocho/test/definition file will
> show you how that is done.
>
> - Ross
>
>
>
> -----Original Message-----
> From: trilinos-users-bounces at software.sandia.gov [mailto:trilinos-
> users-bounces at software.sandia.gov] On Behalf Of Luca Heltai
> Sent: Tuesday, June 10, 2008 8:07 AM
> To: trilinos-users at software.sandia.gov
> Subject: [Trilinos-Users] Moocho question.
>
> Dear Trilinos Users,
>
> I'm trying to use the Moocho module solve a minimization problem for
> which I only have access to the (nonlinear) target g(x,p) and the
> equality constraint f(x,p), and I'm having some difficulties on
> figuring out a couple of things:
>
> I tried running the example
>
> NLPThyraEpetraModelEval4DOpt.exe --no-support-derivs
>
> where I understood from the source code that in this way, all
> derivatives (except W=DfDx) should be computed by Finite Differences.
> Is this assumption correct? If this is correct, then there must be a
> problem somewhere else, since the above does not work: I get the
> following error
>
> ---
> test_nlp = true: Testing the NLP! ...
>
> Testing the supported NLPFirstOrder interface ...
>
> MoochoSolver: Caught an std::exception of type std::logic_error
> described as : /usr/local/trilinos-8.0.5/packages/thyra/src/
> interfaces/nonlinear/model_evaluator/ana/fundamental/
> Thyra_ModelEvaluatorBase.hpp:2292:
>
> Throw number = 1
>
> Throw test that evaluated to true: !deriv.isSupportedBy(derivSupport)
>
> Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports
> (OUT_ARG_DfDp,l):
>
> model = 'Thyra::DefaultFinalPointCaptureModelEvaluator
> {thyraModel='Thyra::DefaultNominalBoundsOverrideModelEvaluator
> {thyraModel='Thyra::DefaultEvaluationLoggerModelEvaluator
> {thyraModel='Thyra::EpetraModelEvaluator
> {epetraModel='EpetraModelEval4DOpt',W_factory='Thyra::AmesosLinearOpWi
> th
> SolveFactory{solverType=Klu}'}'}'}'}':
>
> Error, The argument DfDp(0) = Derivative
> {derivMultiVec=DerivativeMultiVector
> {multiVec=Thyra::DefaultSpmdMultiVector<double>
> {rangeDim=2,domainDim=2},orientation=DERIV_MV_BY_COL}}
> is not supported!
>
> The supported types include DerivativeSupport{none}!
> ---
>
> From the above error lines, I understood that the thing which was
> giving me a problem was "simply" the testing of the NLP interface...
> I switched this off in the config file, run again, and now I get the
> following:
>
>
> ********************************
> *** Start of rSQP Iterations ***
> n = 4, m = 2, nz = 0
>
> k f ||c||s ||rGL||s QN ||Ypy||2 ||Zpz||2 ||d||inf
> alpha time(sec)
> ---- --------- --------- --------- -- -------- -------- --------
> -------- ---------
> 0 0 - - - - -
> - - 0.013418
>
> Total time = 0.013452 sec
>
> Oops! Not the solution. Some error has occured!
>
>
> -----
>
> The program then hangs for a while, until I just kill it...
>
> From the above, my conclusions are:
> 1. I did not understand how this works 2. There is a problem somewhere
> (probably in point 1 above ... ;-) ...)
>
> One last question: In the documentation it is stated:
>
> "MOOCHO also includes a minimally invasive mode for reduced-space SQP
> where the simulator application only needs to compute the objective
> and constraint functions f (xD , xI): R(n+m) -> R, c (xD , xI ):
> R(n+m) -> Rn and solve only forward linear systems involving DcDxD.
> All other derivatives can be approximated with directional finite
> differences but any exact derivatives that can be computed by the
> application are happily accepted and fully utilized by MOOCHO through
> the Thyra::ModelEvaluator interface."
>
> Does this mean that one can also approximate DfDx (=DcDxD) in Moocho
> by finite differences? From the above statement I couldn't figure it
> out (I was hoping yes, but then in the example codes create_W is
> always specified, and trying not to specify it gives errors like the
> one I printed out above).
>
> Assuming that one could calculate W=DfDx in some way, then how do we
> specify that all other derivatives are to be computed by finite
> difference approximations? My understanding was that this is the
> default behavior, unless the various outArgs properties are set
> accordingly. Is this correct? And if so, what is wrong in the example
> test problem when --no-support-derivs is set? The effect of this is
> precisely not to specify the unknown derivatives...
>
> Thanks in advance,
>
> Luca.
>
> --
> Luca Heltai <luca.heltai at gmail.com>
> http://www-dimat.unipv.it/heltai
> --
> There are no answers, only cross references.
>
>
>
>
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> http://software.sandia.gov/mailman/listinfo/trilinos-users
>
More information about the Trilinos-Users
mailing list