root/applications/pmsm/pmsm_ui.h @ 342

Revision 342, 4.0 kB (checked in by smidl, 15 years ago)

Barcelona

Line 
1/*!
2  \file
3  \brief UserInfo for pmsm related objects
4  \author Vaclav Smidl.
5
6  -----------------------------------
7  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
8
9  Using IT++ for numerical operations
10  -----------------------------------
11*/
12
13#include "pmsmDS.h"
14#include <uibuilder.h>
15
16class UIpmsmIM: public UIbuilder {
17        protected:
18        static void tmp_set ( Setting &S, IMpmsm* IM ) {
19                //set_parameters( Rs0, Ls0, dt0, Ypm0, kp0, p0, J0, Mz0 )
20                IM->set_parameters ( S["Rs"], S["Ls"], 125e-6, S["Fmag"], S["kp"],  S["p"], \
21                                S["J"], 0.0 );
22        };
23        public:
24        UIpmsmIM():UIbuilder("pmsmIM"){};
25        bdmroot* build ( Setting &S ) const {
26                IMpmsm* tmp;
27                //Switch to variants
28                if (S.exists("variant")){
29                        string var=S["variant"];
30                        if (var=="Stat"){tmp=new IMpmsmStat;}
31                        if (var=="2o"){tmp=new IMpmsm2o;}
32                        if (var=="Mz"){tmp=new IMpmsmMz;}
33                        if (var=="StatMz"){tmp=new IMpmsmStatMz;}
34                } else {
35                        tmp= new IMpmsm;
36                }
37                //Set parameters (recursively)
38                UIcall<IMpmsm*> ( S["params"], &tmp_set , tmp );
39                return tmp;
40        }       
41};
42UIREGISTER ( UIpmsmIM );
43
44//! UI for pmsm observation model
45class UIpmsmOM: public UIbuilder {
46        public:
47                UIpmsmOM():UIbuilder("pmsmOM"){};
48                bdmroot* build ( Setting &S ) const {
49                        return new OMpmsm;
50                }       
51};
52UIREGISTER ( UIpmsmOM );
53
54
55class UIpmsmOM4: public UIbuilder {
56        public:
57                UIpmsmOM4():UIbuilder("pmsmOM4"){};
58                bdmroot* build ( Setting &S ) const {
59                        return new OMpmsm4;
60                }       
61};
62UIREGISTER ( UIpmsmOM4 );
63
64
65//!UI for pmsmDS,
66class UIpmsmDS: public UIbuilder {
67        static void tmp_set ( Setting &S, pmsmDS* DS ) {
68                //pmsmsim_set_parameters (( Rs0,  Ls0, Fmag0, Bf0, p0, kp0,  J0, Uc0, DT0,  dt0);
69                DS->set_parameters ( S["Rs"], S["Ls"], S["Fmag"], S["Bf"], S["p"], S["kp"], \
70                                     S["J"], S["Uc"], S["DT"], 1.0e-6 );
71        };
72public:
73        UIpmsmDS() :UIbuilder ( "pmsmDS" ) {};
74        bdmroot* build ( Setting &S ) const {
75                pmsmDS* tmp = new pmsmDS ( );
76                //Calling function tmp->tmp_set
77                UIcall<pmsmDS*> ( S["params"], &tmp_set , tmp );
78               
79                // Default values of profiles for omega and Mz
80                vec profW=vec("1.0");
81                vec profM=vec("0.0");
82                double tstep=1.0;
83               
84                if ( S.exists ( "tstep" ) ) {tstep=S["tstep"];}
85                if ( S.exists ( "profileW" ) ) {profW=getvec ( S["profileW"] ) ;}
86                if ( S.exists ( "profileM" ) ) {profM=getvec ( S["profileM"] ) ;}
87               
88                tmp->set_profile (tstep , profW, profM);
89               
90                string opts="";
91                if ( S.exists ( "options" ) ) {opts=(const char*)S["options"];}
92                tmp->set_options(opts);
93               
94                return tmp;
95        };
96
97};
98UIREGISTER ( UIpmsmDS );
99
100class UIpmsmCRB: public UIbuilder {
101        public:
102                UIpmsmCRB():UIbuilder("pmsmCRB"){};
103                bdmroot* build ( Setting &S ) const {
104                        diffbifn* IM; UIbuild(S["IM"],IM);
105                        diffbifn* OM; UIbuild(S["OM"],OM);
106               
107                //parameters
108                        pmsmCRB* E; E=new pmsmCRB;
109               
110                //statistics
111                        int dim=IM->dimension();
112                        vec mu0;
113                        mat P0;
114                        if (S.exists("mu0")){mu0=getvec(S["mu0"]);}else{mu0=zeros(dim);};
115                        if (S.exists("P0")){mu0=getmat(S["P0"],dim);}else{P0=eye(dim);};
116                        E->set_statistics(mu0,P0);
117               
118                        E->set_parameters(IM, OM, diag(getvec(S["dQ"])), diag(getvec(S["dR"])));
119
120                //connect
121                        RV* drv; UIbuild(S["drv"],drv);
122                        E->set_drv(*drv);
123                        RV* rv; UIbuild(S["rv"],rv);
124                        E->set_rv(*rv);
125                        return E;
126                }       
127};
128UIREGISTER ( UIpmsmCRB );
129
130class UIpmsmCRBMz: public UIbuilder {
131        public:
132                UIpmsmCRBMz():UIbuilder("pmsmCRBMz"){};
133                bdmroot* build ( Setting &S ) const {
134                        diffbifn* IM; UIbuild(S["IM"],IM);
135                        diffbifn* OM; UIbuild(S["OM"],OM);
136               
137                //parameters
138                        pmsmCRBMz* E; E=new pmsmCRBMz;
139               
140                //statistics
141                        int dim=IM->dimension();
142                        vec mu0;
143                        mat P0;
144                        if (S.exists("mu0")){mu0=getvec(S["mu0"]);}else{mu0=zeros(dim);};
145                        if (S.exists("dP0")){P0=diag(getvec(S["dP0"]));}else{
146                                if (S.exists("P0")){mu0=getmat(S["P0"],dim);}else{P0=eye(dim);};
147                        }
148                        E->set_statistics(mu0,P0);
149               
150                        E->set_parameters(IM, OM, diag(getvec(S["dQ"])), diag(getvec(S["dR"])));
151
152                //connect
153                        RV* drv; UIbuild(S["drv"],drv);
154                        E->set_drv(*drv);
155                        RV* rv; UIbuild(S["rv"],rv);
156                        E->set_rv(*rv);
157                        return E;
158                }       
159};
160UIREGISTER ( UIpmsmCRBMz );
Note: See TracBrowser for help on using the browser.