1 |
/* |
2 |
Sensitivity add-on for ASCEND |
3 |
by Tom Epperly, Kirk Abbot |
4 |
|
5 |
Copyright (C) 1990-2006 Carnegie-Mellon University |
6 |
|
7 |
This program is free software; you can redistribute it and/or modify |
8 |
it under the terms of the GNU General Public License as published by |
9 |
the Free Software Foundation; either version 2 of the License, or |
10 |
(at your option) any later version. |
11 |
|
12 |
This program is distributed in the hope that it will be useful, |
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
16 |
|
17 |
You should have received a copy of the GNU General Public License |
18 |
along with this program; if not, write to the Free Software |
19 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 |
This file is part of the SLV solver. |
21 |
*/ |
22 |
|
23 |
/** @file |
24 |
@note This is a static package in ASCEND. It can not be built as a dynamic package |
25 |
because it doesn't contain the self-registration stuff. |
26 |
|
27 |
This file attempts to implement the extraction of dy_dx from |
28 |
a system of equations. If one considers a black-box where x are |
29 |
the input variables, u are input parameters, y are the output |
30 |
variables, f(x,y,u) is the system of equations that will be solved |
31 |
for given x and u, then one can extract the sensitivity information |
32 |
of y wrt x. |
33 |
|
34 |
One crude but simple way of doing this is to finite-difference the |
35 |
given black box, i.e, perturb x, n\subx times by delta x, resolve |
36 |
the system of equations at the new value of x, and compute |
37 |
dy/dx = (f(x\sub1) - f(x\sub2))/(x\sub1 - x\sub2). |
38 |
This is known to be very expensive. |
39 |
|
40 |
The solution that will be adopted here is to formulate the Jacobian J of |
41 |
the system, (or the system is already solved, to grab the jacobian at |
42 |
the solution. Develop the sensitivity matrix df/dx by exact numnerical |
43 |
differentiation; this will be a n x n\subx matrix. Compute the LU factors |
44 |
for J, and to solve column by column to : LU dz/dx = df/dx. Here |
45 |
z, represents all the internal variables to the system and the strictly |
46 |
output variables y. In other words J = df/dz. |
47 |
|
48 |
Given the solution of the above problem we then simply extract the rows |
49 |
of dz/dx, that pertain to the y variables that we are interested in; |
50 |
this will give us dy/dx. |
51 |
|
52 |
@todo Do we really need 2 files called [Ss]ensitivity.[ch]? Other one is in tcltk. |
53 |
|
54 |
@todo Make this self-registering so that it can be compiled as a dlopenable library. |
55 |
*/ |
56 |
|
57 |
/** @file |
58 |
Requires: |
59 |
#include <utilities/ascConfig.h> |
60 |
#include <compiler/instance_enum.h> |
61 |
#include <compiler/compiler.h> |
62 |
#include <general/list.h> |
63 |
#include <compiler/extfunc.h> |
64 |
*/ |
65 |
|
66 |
#ifndef ASC_SENSITIVITY_H |
67 |
#define ASC_SENSITIVITY_H |
68 |
|
69 |
/* ignores: interp, i, whichvar */ |
70 |
extern int do_solve_eval( struct Instance *i, struct gl_list_t *arglist); |
71 |
|
72 |
/* ignores: interp, i, whichvar */ |
73 |
extern int do_finite_diff_eval( struct Instance *i, struct gl_list_t *arglist); |
74 |
|
75 |
extern char sensitivity_help[]; |
76 |
|
77 |
/* ignores: interp, i, */ |
78 |
extern int do_sensitivity_eval_all( struct Instance *i, struct gl_list_t *arglist); |
79 |
|
80 |
/* ignores: interp, i, */ |
81 |
extern int do_sensitivity_eval( struct Instance *i, struct gl_list_t *arglist); |
82 |
|
83 |
ASC_DLLSPEC(int) sensitivity_register(void); |
84 |
|
85 |
#endif /* ASC_SENSITIVITY_H */ |
86 |
|