Actual source code: taoapp_ga.h
1: //File taoapp_ga.h
3: /**************************************************************
5: Author: Limin Zhang, Ph.D.
6: Mathematics Department
7: Columbia Basin College
8: Pasco, WA 99301
9: Limin.Zhang@cbc2.org
11: Mentor: Jarek Naplocha, Ph.D.
12: Environmental Molecular Science Laboratory
13: Pacific Northwest National Laboratory
14: Richland, WA 99352
16: Date: 7/22/2002
18: Purpose:
19: to design and implement an applicaton interface
20: between TAO and global arrays.
22: Revise histroy:
24: 8/9/02
25: To get rid of Petsc calls and marcos.
26:
27: **************************************************************/
29: #ifndef TAOGAAPP_H
30: #define TAOGAAPP_H
32: #include "taoappobject.h"
33: #include "taovec_ga.h"
34: #include "taomat_ga.h"
37: #ifndef MAX_TAO_MONITORS
38: #define MAX_TAO_MONITORS 5
39: #endif
41: class TaoGAApplication: public TaoApplication{
43: protected:
45: public:
46: TaoGAApplication(MPI_Comm comm);
47: ~TaoGAApplication();
49: MPI_Comm comm;
51: /* Function Evaluation */
52: TaoVecGa *taox; /* The Variable Vector */
53: GAVec V;
54: void *usrfctx;
55: virtual int GetVariableVector(TaoVec **);
56: int (*computeumfunction)(TaoGAApplication*,GAVec,double*,void*);
57: virtual int EvaluateObjectiveFunction(TaoVec *xx, double *ff);
59: /* Gradient Evaluation */
60: void *usrgctx;
61: int (*computegradient)(TaoGAApplication*,GAVec,GAVec,void*);
62: virtual int EvaluateGradient(TaoVec *xx, TaoVec *gg);
64: /* Function and Gradient */
65: void *usrfgctx;
66: int (*computefunctiongradient)(TaoGAApplication*,GAVec,double*,GAVec,void*);
67: int EvaluateObjectiveAndGradient(TaoVec *xx, double *ff, TaoVec *gg);
69: /* Hessian Evaluation */
70: GAMat HesMat;
71: TaoMatGa *taoh; /* The Hessian Matrix */
72: void *usrhctx;
73: virtual int GetHessianMatrix(TaoMat **HH);
74: int (*computehessian)(TaoGAApplication*,GAVec,GAMat,void*);
75: virtual int EvaluateHessian(TaoVec *xx, TaoMat *HH);
77: /* Set Variable Bounds */
78: TaoVecGa *taoxl; /* The Lower Bounds on the Variable Vector */
79: TaoVecGa *taoxu; /* The Upper Bounds on the Variable Vector */
81: virtual int EvaluateVariableBounds(TaoVec *xxll, TaoVec *xxuu);
82: void *usrvbctx;
83: int (*computebounds)(TaoGAApplication*, GAVec, GAVec, void*);
85: virtual int InitializeVariables(TaoVec *x);
87: /* Monitoring */
88: int numbermonitors; // # of monitors
89: int (*monitor[MAX_TAO_MONITORS])(TaoGAApplication*, void*);// monitor routines
90: void *monitorcontext[MAX_TAO_MONITORS]; // monitor contexts
93: };
96: // C stubs
97: typedef TaoGAApplication* TAO_GA_APPLICATION;
98: int TaoGAApplicationCreate(MPI_Comm comm, TAO_GA_APPLICATION* newapp);
99: int TaoGAAppDestroy(TAO_GA_APPLICATION gaapp);
100: int TaoGAAppSetObjectiveRoutine(TAO_GA_APPLICATION gaapp, GAVec X,
101: int (*func)(TAO_GA_APPLICATION,GAVec,double*,void*),void *ctx);
102: int TaoGAAppSetGradientRoutine(TAO_GA_APPLICATION gaapp,
103: int (*grad)(TAO_GA_APPLICATION,GAVec,GAVec,void*),void *ctx);
104: int TaoGAAppSetObjectiveAndGradientRoutine(TAO_GA_APPLICATION gaapp,
105: int (*funcgrad)(TAO_GA_APPLICATION,GAVec,double*,GAVec, void*),
106: void *ctx);
107: int TaoGAAppSetHessianRoutine(TAO_GA_APPLICATION gaapp,
108: int (*hess)(TAO_GA_APPLICATION, GAVec, GAMat,void*),void *ctx);
109: int TaoGAAppSetVariableVec(TAO_GA_APPLICATION gaapp, GAVec X);
110: int TaoGAAppSetInitialSolutionVec(TAO_GA_APPLICATION gaapp, GAVec X0);
111: int TaoGAAppSetVariableBoundsRoutine(TAO_GA_APPLICATION gaapp,
112: int (*func)(TAO_GA_APPLICATION, GAVec, GAVec, void*), void *ctx);
113: int TaoSolveGAApplication(TAO_GA_APPLICATION gaapp, TAO_SOLVER tao);
114: int TaoSetupGAApplicationSolver(TAO_GA_APPLICATION gaapp, TAO_SOLVER tao);
115: int TaoGAAppSetMonitor(TAO_GA_APPLICATION gaapp, int (*mymonitor)(TAO_GA_APPLICATION, void*), void *mctx);
116: int TaoGAAppMonitor(TAO_GA_APPLICATION gaapp);
117: #endif