snopt76_adapter.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 Copyright (c) 2017, Alexander W. Winkler, ETH Zurich. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without modification,
00005 are permitted provided that the following conditions are met:
00006     * Redistributions of source code must retain the above copyright notice,
00007       this list of conditions and the following disclaimer.
00008     * Redistributions in binary form must reproduce the above copyright notice,
00009       this list of conditions and the following disclaimer in the documentation
00010       and/or other materials provided with the distribution.
00011     * Neither the name of ETH ZURICH nor the names of its contributors may be
00012       used to endorse or promote products derived from this software without
00013       specific prior written permission.
00014 
00015 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00016 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00017 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00018 DISCLAIMED. IN NO EVENT SHALL ETH ZURICH BE LIABLE FOR ANY DIRECT, INDIRECT,
00019 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00020 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00022 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00023 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00024 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 ******************************************************************************/
00026 
00027 #ifndef IFOPT_INCLUDE_OPT_SNOPT76_ADAPTER_H_
00028 #define IFOPT_INCLUDE_OPT_SNOPT76_ADAPTER_H_
00029 
00030 #include <snoptProblem.hpp>
00031 
00032 #include <ifopt/problem.h>
00033 
00034 namespace ifopt {
00035 
00050 class SnoptAdapter : public snoptProblemA {
00051 public:
00052   using NLPPtr  = Problem*;
00053   using VectorXd = Problem::VectorXd;
00054   using Jacobian = Problem::Jacobian;
00055 
00060   SnoptAdapter (Problem& nlp);
00061   virtual ~SnoptAdapter () = default;
00062 
00067   static void Solve(Problem& nlp);
00068 
00069 private:
00080   static void SetOptions(SnoptAdapter&);
00081 
00082 private:
00083   void Init();
00084   static void ObjectiveAndConstraintFct(int   *Status, int *n,    double x[],
00085                                         int   *needF,  int *neF,  double F[],
00086                                         int   *needG,  int *neG,  double G[],
00087                                         char     *cu,  int *lencu,
00088                                         int     iu[],  int *leniu,
00089                                         double  ru[],  int *lenru);
00090 
00091   void SetVariables();
00092 
00093   static NLPPtr nlp_; // use raw pointer as SnoptAdapter doesn't own the nlp.
00094 
00095 
00096   // additional variables as Snopt76 base class doesn't have them, not really
00097   // necessary but to keep the same structure of the original SnoptAdapter
00098 protected:
00099 
00100   int     jacComputed = 0;
00101   int     n = 0;
00102   int     neF = 0;
00103   int     ObjRow;
00104   double  ObjAdd;
00105 
00106   double *x, *xlow, *xupp, *xmul;
00107   double *F, *Flow, *Fupp, *Fmul;
00108 
00109   int    *xstate, *Fstate;
00110 
00111   int     lenA, lenG, neA, neG;
00112   int    *iAfun, *jAvar, *iGfun, *jGvar;
00113   double *A;
00114 
00115 };
00116 
00117 } /* namespace opt */
00118 
00119 #endif /* IFOPT_INCLUDE_OPT_SNOPT76_ADAPTER_H_ */


ifopt_snopt
Author(s): Alexander W. Winkler
autogenerated on Sat Apr 21 2018 03:01:50