58 unsigned int iNumRows,
59 unsigned int iNumCols,
60 unsigned int iNumSubMats,
66 for (
unsigned int k = 0; k < iNumSubMats; k++) {
67 int iShift = iNumCols*k;
70 for (
unsigned int i = 0; i < iNumRows; i++) {
71 doublereal* pdTmp = pd + iShift + iNumSubMats*iNumCols*i;
74 for (
unsigned int j = 0; j < iNumCols; j++) {
77 silent_cerr(
"Error: unexpected end of stream while reading "
78 << sMatName <<
'_' << k + 1
79 <<
'(' << i + 1 <<
',' << j + 1 <<
')'
86 <<
"(" << i <<
"," << j <<
") = " << pdTmp[j]
99 const std::string& infile)
100 : iNumOutputs(iNumOut),
144 pd += iNumInputs*iNumInputs*
iOrderB;
154 for (
int i = iSize; i-- > 0; ) {
168 std::ifstream In(infile.c_str());
170 silent_cerr(
"DiscreteControlARXProcess_Debug: "
171 "unable to open control data file \"" << infile <<
"\""
177 ReadMatrix(In,
pdB, iNumInputs, iNumInputs, iOrderB,
"beta");
199 const std::vector<doublereal>& dIn,
200 const std::vector<doublereal>& )
236 for (
int i = iNumInputs; i-- > 0; ) {
237 for (
int j = iRefA*iNumOutputs; j-- > 0; ) {
241 for (
int j = (
iOrderA-iRefA)*iNumOutputs; j-- > 0; ) {
243 pdU0[i] += pdMatOff[0]*pdVecOff[j];
249 for (
int i = iNumInputs; i-- > 0; ) {
250 for (
int j = iRefB*iNumInputs; j-- > 0; ) {
254 for (
int j = (
iOrderB-iRefB)*iNumInputs; j-- > 0; ) {
256 pdU0[i] += pdMatOff[0]*pdVecOff[j];
273 const std::string& sf)
274 : iNumOutputs(iNumOut), iNumInputs(iNumIn),
275 iOrderA(iOrdA), iOrderB(iOrdB), pId(0), pPx(px),
293 silent_cerr(
"DiscreteIdentProcess_Debug: "
294 "unknown model type " << f_proc << std::endl);
338 const std::vector<doublereal>& dIn,
339 const std::vector<doublereal>& )
346 silent_cerr(
"buffer is too small" << std::endl);
351 out << std::setw(16) <<
buf[i];
371 std::vector<DriveCaller *>& vDesOut,
372 const std::string& sf,
374 : iNumOutputs(iNumOut),
394 pId(0), pCD(pd), pPx(px), Trigger(pTrig),
431 + iNumOutputs*iNumOutputs*
iOrderA;
442 if ((f_proc & DISCPROC_MA) == DISCPROC_MA) {
447 for (
int i = iSize; i-- > 0; ) {
474 silent_cerr(
"DAC_Process_Debug: "
475 "unknown identification type " << f_proc
480 if (!vDesOut.empty()) {
520 for (std::vector<DriveOwner *>::iterator i =
vDesiredOut.begin();
546 const std::vector<doublereal>& dIn,
547 const std::vector<doublereal>& dDesiredOut)
614 if (!dDesiredOut.empty()) {
616 pdOff[i] += dDesiredOut[i];
629 for (
int i = iNumInputs; i-- > 0; ) {
630 for (
int j = iRefA*iNumOutputs; j-- > 0; ) {
636 pdU0[i] += pdMatOff[0]*pdVecOff[j];
642 for (
int i = iNumInputs; i-- > 0; ) {
643 for (
int j = iRefB*iNumInputs; j-- > 0; ) {
649 pdU0[i] += pdMatOff[0]*pdVecOff[j];
657 for (
int i = iNumInputs; i-- > 0; ) {
658 for (
int j = iRefA*iNumOutputs; j-- > 0; ) {
664 pdU0[i] += pdMatOff[0]*pdVecOff[j];
673 for (
int i = iNumInputs; i-- > 0; ) {
674 for (
int j =
iRefMd*iNumOutputs; j-- > 0; ) {
680 pdU0[i] += pdMatOff[0]*pdVecOff[j];
693 std::vector<ScalarValue *>& vOut,
694 std::vector<DriveCaller *>& vOutSF,
706 iNumOutputs(iNumOut),
730 for (std::vector<doublereal>::iterator i =
dIn.begin();
736 for (std::vector<doublereal>::iterator i =
dOut.begin();
737 i !=
dOut.end(); ++i)
745 for (std::vector<DriveOwner *>::iterator i =
vOutScaleFact.begin();
751 for (std::vector<ScalarValue *>::iterator i =
vOutputs.begin();
774 out <<
" electric: " <<
GetLabel() <<
", discrete control; "
775 "# to be implemented" << std::endl;
832 WorkVec.
PutItem(iCnt + 1,
pInputs[iCnt].pNode->iGetFirstRowIndex() + 1,
dIn[iCnt]);
849 ASSERTMSG(0,
"You shouldn't have called this function");
906 long idx = std::strtol(s, &next, 10);
907 int save_errno = errno;
908 if (next == s || next[0] !=
']') {
912 if (save_errno == ERANGE) {
913 silent_cerr(
"DiscreteControlElem(" <<
GetLabel() <<
"): "
914 "warning, private data index " << std::string(s, next - s)
915 <<
" overflows" << std::endl);
940 std::vector<const Node *>& connectedNodes)
const {
946 unsigned cnt = unsigned(iNumInputs);
950 connectedNodes[cnt] = psdv->
pNode;
955 ASSERT(cnt <= connectedNodes.size());
957 if (cnt != connectedNodes.size()) {
958 connectedNodes.resize(cnt);
integer iGetNumOutput(void) const
std::vector< doublereal > dOut
#define MBDYN_EXCEPT_ARGS
const std::string outfile
virtual void AfterConvergence(const VectorHandler &X, const VectorHandler &XP)
virtual void ResizeReset(integer)
std::vector< DriveOwner * > vOutScaleFact
virtual doublereal dGetForgettingFactor(void)
void GetInput(std::vector< doublereal > &dIn)
std::vector< doublereal > dIn
std::vector< DriveOwner * > vDesiredOut
#define SAFEDELETEARR(pnt)
DAC_Process_Debug(integer iNumOut, integer iNumIn, integer iOrdA, integer iOrdB, ForgettingFactor *pf, GPCDesigner *pd, PersistentExcitation *px, DriveCaller *PTrig, std::vector< DriveCaller * > &vDesOut, const std::string &sf, unsigned f_proc)
#define ASSERTMSG(expr, msg)
virtual unsigned int iGetPrivDataIdx(const char *s) const
virtual Electric::Type GetElectricType(void) const
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal, const VectorHandler &, const VectorHandler &)
virtual ~DiscreteControlProcess(void)
virtual void PutItem(integer iSubRow, integer iRow, const doublereal &dCoef)
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
DiscreteControlProcess * pDCP
virtual ~DAC_Process_Debug(void)
PersistentExcitation * pPx
std::vector< ScalarValue * > vOutputs
void GetInput(std::vector< doublereal > &dIn)
void PutOutput(const std::vector< doublereal > &dOut, const std::vector< doublereal > &dIn, const std::vector< doublereal > &dDesiredOut)
const std::string outfile
PersistentExcitation * pPx
virtual void Update(const doublereal *pdY, const doublereal *pdU)=0
DiscreteIdentProcess_Debug(integer iNumOut, integer iNumIn, integer iOrdA, integer iOrdB, ForgettingFactor *pf, PersistentExcitation *px, unsigned f_proc, const std::string &sf)
#define ASSERT(expression)
virtual void GetTheta(doublereal *pdTheta)=0
virtual ~DiscreteControlARXProcess_Debug(void)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
virtual void GetConnectedNodes(std::vector< const Node * > &connectedNodes) const
virtual void PutOutput(const std::vector< doublereal > &dOut, const std::vector< doublereal > &dIn, const std::vector< doublereal > &dDesiredOut)=0
void GetInput(std::vector< doublereal > &dIn)
const unsigned long BUFSIZE
virtual integer iGetSize(void) const =0
virtual ~DiscreteControlElem(void)
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
virtual ~DiscreteIdentProcess_Debug(void)
virtual void GetErr(doublereal *pdE)
virtual unsigned int iGetNumDof(void) const
doublereal dGet(const doublereal &dVar) const
int ReadMatrix(std::istream &In, doublereal *pd, unsigned int iRows, unsigned int iCols, unsigned int iNumSubMats, const char *sMatName)
virtual void GetInput(std::vector< doublereal > &dIn)=0
integer iGetPredHor(void) const
static const std::vector< doublereal > dEmptyDesiredOut
#define SAFENEWARR(pnt, item, sz)
integer iGetPredStep(void) const
virtual void AddInput(doublereal *pd) const =0
DiscreteControlElem(unsigned int uL, const DofOwner *pDO, integer iNumOut, std::vector< ScalarValue * > &vOut, std::vector< DriveCaller * > &vOutSF, integer iNumIn, ScalarDof *ppIn, DiscreteControlProcess *p, integer iNIt, flag fOut)
virtual void DesignControl(const doublereal *, doublereal **ppda=NULL, doublereal **ppdb=NULL, doublereal **ppdm=NULL, doublereal **ppdc=NULL)
static doublereal buf[BUFSIZE]
void PutOutput(const std::vector< doublereal > &dOut, const std::vector< doublereal > &dIn, const std::vector< doublereal > &dDesiredOut)
virtual std::ostream & Restart(std::ostream &out) const
DiscreteControlARXProcess_Debug(integer iNumOut, integer iNumIn, integer iOrdA, integer iOrdB, const std::string &infile)
void PutOutput(const std::vector< doublereal > &dOut, const std::vector< doublereal > &dIn, const std::vector< doublereal > &dDesiredOut)
unsigned int GetLabel(void) const
const doublereal & dGetValue(void) const
#define DEBUGLCOUT(level, msg)
virtual DofOrder::Order GetDofType(unsigned int) const
virtual doublereal dGetPrivData(unsigned int i) const
virtual unsigned int iGetNumPrivData(void) const