-
Notifications
You must be signed in to change notification settings - Fork 0
/
optcon.h
99 lines (98 loc) · 2.86 KB
/
optcon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "cg_descent.h"
#include "st_descent.h"
typedef struct optcon_struct
{
int n;
int nx;
int nc;
int ns;
double t_0;
double t_f;
double h;
double *state_0;
double *state_f;
double *state;
double *costate;
double *gx;
double *gu;
double *y;
double *z;
double *a;
double *b;
double *c;
double *tau;
double *cg_work;
} optcon_work;
typedef struct optcon_parameter
{
int PrintLevel;
int PrintFinal;
int scheme;
} optcon_parameter;
/* ---------------------------------------
prototype of user defined functions
--------------------------------------- */
void (*optcon_f)(double *, double *, double *, double) ;// evaluate f(x)
void (*optcon_dphi)(double *, double *) ;// evaluate of dF/dx
double (*optcon_phi)(double *) ;//evaluate of F
void (*optcon_fu)(double *, double *, double *, double) ;//evaluate df/du
void (*optcon_fx)(double *, double *, double *, double) ;//evaluate df/dx
/* ---------------------------------------
prototype of optcon functions
--------------------------------------- */
int optcon_setup
(
int n, /* number of time mesh intervals*/
int nx, /* number of state variables */
int nc, /* number of controllers */
int ns, /* number of stage in Runge-Kutta scheme*/
double t_0, /* start time */
double t_f, /* finish time */
double *state_0, /* initial states */
double *state, /* state variables */
double *a, /* Runge-Kutta scheme A */
double *b, /* Runge-Kutta scheme B */
optcon_parameter *parm
) ;
void optcon_gradient
(
double *g, // ptr of the gradient vector of F respect to u
double *control // ptr of the control
) ;
double optcon_cost
(
double *control
) ;
void optcon_state
(
double *control
) ;
void optcon_costate
(
double *control
) ;
void optcon_combine
(
double *g,
double *control
) ;
int optcon
(
double grad_tol, /* gradient tolerance to be used in cg_descent */
int n, /* number of time mesh intervals*/
int nx, /* number of state variables */
int nc, /* number of controllers */
int ns, /* number of stage in Runge-Kutta scheme*/
double t_0, /* start time */
double t_f, /* finish time */
double *control, /* control variables */
double *state_0, /* initial states */
double *state, /* state variables */
double *a, /* Runge-Kutta scheme A */
double *b, /* Runge-Kutta scheme B */
double (*phi)(double *),
void (*dphi)(double *, double *),
void (*f)(double *, double *, double *, double),
void (*fx)(double *, double *, double *, double),
void (*fu)(double *, double *, double *, double)
) ;