00001
00017 #include "OSnLNode.h"
00018 #include "ErrorClass.h"
00019 #include "OSParameters.h"
00020
00021 #include<string>
00022
00023 #ifdef HAVE_CMATH
00024 # include <cmath>
00025 #else
00026 # ifdef HAVE_MATH_H
00027 # include <math.h>
00028 # else
00029 # error "don't have header file for math"
00030 # endif
00031 #endif
00032
00033
00034 #include <iostream>
00035 #include <sstream>
00036
00037
00038 using std::ostringstream;
00039 using std::cout;
00040 using std::endl;
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 OSnLNode::OSnLNode():
00155 snodeName(""),
00156 m_mChildren(NULL),
00157 m_dFunctionValue( OSNAN)
00158
00159 {
00160 }
00161
00162 OSnLNode::~OSnLNode(){
00163 #ifdef DEBUGOSNLNODE
00164 cout << "inside OSnLNode destructor" << endl;
00165 #endif
00166 }
00167
00168
00169 OSnLNode* OSnLNode::createExpressionTreeFromPostfix(std::vector<OSnLNode*> nlNodeVec){
00170 std::vector<OSnLNode*> stackVec ;
00171 unsigned int kount = 0;
00172 while(kount <= nlNodeVec.size() - 1){
00173 int numkids = nlNodeVec[kount]->inumberOfChildren;
00174 if(numkids > 0){
00175 for(int i = numkids - 1; i >= 0; i--){
00176 nlNodeVec[kount]->m_mChildren[i] = stackVec.back() ;
00177 stackVec.pop_back();
00178 }
00179 }
00180 stackVec.push_back( nlNodeVec[kount]);
00181 kount++;
00182 }
00183 stackVec.clear();
00184 return nlNodeVec[ kount - 1];
00185 }
00186
00187 std::vector<OSnLNode*> OSnLNode::getPostfixFromExpressionTree( ){
00188 std::vector<OSnLNode*> postfixVector;
00189 return postOrderOSnLNodeTraversal( &postfixVector);
00190 }
00191
00192 std::vector<OSnLNode*> OSnLNode::postOrderOSnLNodeTraversal( std::vector<OSnLNode*> *postfixVector){
00193 if(inumberOfChildren > 0){
00194 int i;
00195 for(i = 0; i < inumberOfChildren; i++)
00196 m_mChildren[i]->postOrderOSnLNodeTraversal( postfixVector);
00197 }
00198 (*postfixVector).push_back( this);
00199 return *postfixVector;
00200 }
00201
00202 OSnLNode* OSnLNode::createExpressionTreeFromPrefix(std::vector<OSnLNode*> nlNodeVec){
00203 std::vector<OSnLNode*> stackVec;
00204 int kount = nlNodeVec.size() - 1;
00205 while(kount >= 0){
00206 int numkids = nlNodeVec[kount]->inumberOfChildren;
00207 if(numkids > 0){
00208 for(int i = 0; i < numkids; i++){
00209 nlNodeVec[kount]->m_mChildren[i] = stackVec.back() ;
00210 stackVec.pop_back();
00211 }
00212 }
00213 stackVec.push_back( nlNodeVec[kount]);
00214 kount--;
00215 }
00216 stackVec.clear();
00217 return nlNodeVec[ 0];
00218 }
00219
00220 std::vector<OSnLNode*> OSnLNode::getPrefixFromExpressionTree(){
00221 std::vector<OSnLNode*> prefixVector;
00222 return preOrderOSnLNodeTraversal( &prefixVector);
00223 }
00224
00225 std::vector<OSnLNode*> OSnLNode::preOrderOSnLNodeTraversal( std::vector<OSnLNode*> *prefixVector){
00226 (*prefixVector).push_back( this);
00227 if(inumberOfChildren > 0){
00228 for(int i = 0; i < inumberOfChildren; i++)
00229 m_mChildren[i]->preOrderOSnLNodeTraversal( prefixVector);
00230 }
00231 return *prefixVector;
00232 }
00233
00234
00235 std::string OSnLNode::getTokenNumber(){
00236 ostringstream outStr;
00237 outStr << inodeInt;
00238
00239 if(inodeType == -1){
00240 outStr << "[";
00241 outStr << inumberOfChildren ;
00242 outStr << "]";
00243 }
00244 return outStr.str();
00245 }
00246
00247
00248 std::string OSnLNode::getTokenName(){
00249 ostringstream outStr;
00250 outStr << this->snodeName;
00251 if(inodeType == -1){
00252 outStr << "[";
00253 outStr << inumberOfChildren ;
00254 outStr << "]";
00255 }
00256 return outStr.str();
00257 }
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363 std::string OSnLNode::getNonlinearExpressionInXML(){
00364 ostringstream outStr;
00365 outStr << "<" ;
00366 outStr << snodeName;
00367 if(inumberOfChildren > 0) {
00368 outStr << ">";
00369 }
00370 else{
00371 outStr << "/>";
00372 }
00373 if(inumberOfChildren > 0){
00374 for(int i = 0; i < inumberOfChildren; i++){
00375 outStr << m_mChildren[i]->getNonlinearExpressionInXML();
00376 }
00377 }
00378 if(inumberOfChildren > 0) {
00379 outStr << "</" ;
00380 outStr << snodeName ;
00381 outStr << ">" ;
00382 }
00383 return outStr.str();
00384 }
00385
00386
00387
00388
00389 void OSnLNode::getVariableIndexMap(std::map<int, int> *varIdx){
00390 int i;
00391 if(inodeInt != OS_VARIABLE){
00392 for(i = 0; i < inumberOfChildren; i++){
00393 m_mChildren[ i]->getVariableIndexMap( varIdx);
00394 }
00395 }
00396 }
00397
00398
00399 OSnLNodePlus::OSnLNodePlus()
00400 {
00401 snodeName = "plus";
00402 inumberOfChildren = 2;
00403 m_mChildren = new OSnLNode*[2];
00404 m_mChildren[ 0] = NULL;
00405 m_mChildren[ 1] = NULL;
00406 inodeInt = 1001;
00407 inodeType = 2;
00408 }
00409
00410 OSnLNodePlus::~OSnLNodePlus(){
00411 #ifdef DEBUGOSNLNODE
00412 cout << "inside OSnLNodePlus destructor" << endl;
00413 #endif
00414 for(int i = 0; i < inumberOfChildren; i++){
00415 if( m_mChildren[ i] != NULL) delete m_mChildren[ i];
00416 m_mChildren[i] = NULL;
00417 }
00418 m_mChildren = NULL;
00419 }
00420
00421
00422 double OSnLNodePlus::calculateFunction(double *x){
00423 m_dFunctionValue = m_mChildren[0]->calculateFunction(x) + m_mChildren[1]->calculateFunction(x);
00424 return m_dFunctionValue;
00425 }
00426
00427
00428 AD<double> OSnLNodePlus::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00429 m_CppADTape = m_mChildren[0]->constructCppADTape( cppADIdx, XAD) + m_mChildren[1]->constructCppADTape( cppADIdx, XAD);
00430 return m_CppADTape;
00431 }
00432
00433
00434 OSnLNode* OSnLNodePlus::cloneOSnLNode(){
00435 OSnLNode *nlNodePoint;
00436 nlNodePoint = new OSnLNodePlus();
00437 return nlNodePoint;
00438 }
00439
00440
00441
00442 OSnLNodeSum::OSnLNodeSum()
00443 {
00444 inumberOfChildren = 0;
00445 snodeName = "sum";
00446 inodeInt = 1002;
00447 inodeType = -1;
00448 }
00449
00450 OSnLNodeSum::~OSnLNodeSum(){
00451 #ifdef DEBUGOSNLNODE
00452 cout << "inside OSnLNodeSum destructor" << endl;
00453 #endif
00454 if(inumberOfChildren > 0){
00455 for(int i = 0; i < inumberOfChildren; i++){
00456 delete m_mChildren[ i];
00457 m_mChildren[i] = NULL;
00458 }
00459 }
00460 m_mChildren = NULL;
00461 }
00462
00463 double OSnLNodeSum::calculateFunction(double *x){
00464 m_dFunctionValue = 0.0;
00465 int i;
00466 for(i = 0; i < inumberOfChildren; i++){
00467 m_dFunctionValue = m_dFunctionValue + m_mChildren[i]->calculateFunction(x);
00468 }
00469 return m_dFunctionValue;
00470 }
00471
00472
00473 AD<double> OSnLNodeSum::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00474 m_CppADTape = 0.0;
00475 int i;
00476 for(i = 0; i < inumberOfChildren; i++){
00477 m_CppADTape = m_CppADTape + m_mChildren[i]->constructCppADTape( cppADIdx, XAD);
00478 }
00479 return m_CppADTape;
00480 }
00481
00482 OSnLNode* OSnLNodeSum::cloneOSnLNode(){
00483 OSnLNode *nlNodePoint;
00484 nlNodePoint = new OSnLNodeSum();
00485 return nlNodePoint;
00486 }
00487
00488
00489
00490
00491
00492 OSnLNodeAllDiff::OSnLNodeAllDiff()
00493 {
00494 inumberOfChildren = 0;
00495 snodeName = "allDiff";
00496 inodeInt = 7016;
00497 inodeType = -1;
00498 }
00499
00500 OSnLNodeAllDiff::~OSnLNodeAllDiff(){
00501 #ifdef DEBUGOSNLNODE
00502 cout << "inside OSnLNodeAllDiff destructor" << endl;
00503 #endif
00504 if(inumberOfChildren > 0){
00505 for(int i = 0; i < inumberOfChildren; i++){
00506 delete m_mChildren[ i];
00507 m_mChildren[i] = NULL;
00508 }
00509 }
00510 m_mChildren = NULL;
00511 }
00512
00513 double OSnLNodeAllDiff::calculateFunction(double *x){
00514 m_dFunctionValue = 1;
00515
00516 int i, k;
00517 if(inumberOfChildren > 1){
00518 for(i = 0; i < inumberOfChildren - 1; i++){
00519 for(k = i + 1; k < inumberOfChildren; k++){
00520 if(m_mChildren[i]->calculateFunction(x) ==
00521 m_mChildren[k]->calculateFunction(x)) return 0 ;
00522 }
00523 }
00524 }
00525 return m_dFunctionValue;
00526 }
00527
00528
00529 AD<double> OSnLNodeAllDiff::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00530 try{
00531 throw ErrorClass("AllDifferent operator not supported by current Algorithmic Differentiation implementation");
00532 return m_CppADTape;
00533 }
00534 catch(const ErrorClass& eclass){
00535 throw ErrorClass( eclass.errormsg);
00536 }
00537 return m_CppADTape;
00538 }
00539
00540 OSnLNode* OSnLNodeAllDiff::cloneOSnLNode(){
00541 OSnLNode *nlNodePoint;
00542 nlNodePoint = new OSnLNodeAllDiff();
00543 return nlNodePoint;
00544 }
00545
00546
00547
00548
00549
00550
00551 OSnLNodeMax::OSnLNodeMax()
00552 {
00553 inumberOfChildren = 0;
00554 snodeName = "max";
00555 inodeInt = 4011;
00556 inodeType = -1;
00557 }
00558
00559 OSnLNodeMax::~OSnLNodeMax(){
00560 #ifdef DEBUGOSNLNODE
00561 cout << "inside OSnLNodeMax destructor" << endl;
00562 #endif
00563 if(inumberOfChildren > 0){
00564 for(int i = 0; i < inumberOfChildren; i++){
00565 delete m_mChildren[ i];
00566 m_mChildren[i] = NULL;
00567 }
00568 }
00569 m_mChildren = NULL;
00570 }
00571
00572 double OSnLNodeMax::calculateFunction(double *x){
00573 m_dFunctionValue = m_mChildren[0]->calculateFunction(x);
00574 if(inumberOfChildren > 1){
00575 for(int i = 1; i < inumberOfChildren; i++){
00576 if(m_mChildren[i]->calculateFunction(x) > m_dFunctionValue){
00577 m_dFunctionValue = m_mChildren[i]->calculateFunction(x);
00578 }
00579 }
00580 }
00581 return m_dFunctionValue;
00582 }
00583
00584
00585 AD<double> OSnLNodeMax::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00586
00587 try{
00588 throw ErrorClass("Max operator not supported by current Algorithmic Differentiation implementation");
00589 return m_CppADTape;
00590 }
00591 catch(const ErrorClass& eclass){
00592 throw ErrorClass( eclass.errormsg);
00593 }
00594 }
00595
00596
00597 OSnLNode* OSnLNodeMax::cloneOSnLNode(){
00598 OSnLNode *nlNodePoint;
00599 nlNodePoint = new OSnLNodeMax();
00600 return nlNodePoint;
00601 }
00602
00603
00604
00605
00606
00607
00608 OSnLNodeMin::OSnLNodeMin()
00609 {
00610 inumberOfChildren = 0;
00611 snodeName = "min";
00612 inodeInt = 4010;
00613 inodeType = -1;
00614 }
00615
00616 OSnLNodeMin::~OSnLNodeMin(){
00617 #ifdef DEBUGOSNLNODE
00618 cout << "inside OSnLNodeMin destructor" << endl;
00619 #endif
00620 if(inumberOfChildren > 0){
00621 for(int i = 0; i < inumberOfChildren; i++){
00622 delete m_mChildren[ i];
00623 m_mChildren[i] = NULL;
00624 }
00625 }
00626 m_mChildren = NULL;
00627 }
00628
00629 double OSnLNodeMin::calculateFunction(double *x){
00630 m_dFunctionValue = m_mChildren[0]->calculateFunction(x);
00631 if(inumberOfChildren > 1){
00632 for(int i = 1; i < inumberOfChildren; i++){
00633 if(m_mChildren[i]->calculateFunction(x) < m_dFunctionValue){
00634 m_dFunctionValue = m_mChildren[i]->calculateFunction(x);
00635 }
00636 }
00637 }
00638 return m_dFunctionValue;
00639 }
00640
00641
00642 AD<double> OSnLNodeMin::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00643
00644 try{
00645 throw ErrorClass("Min operator not supported by current Algorithmic Differentiation implementation");
00646 return m_CppADTape;
00647 }
00648 catch(const ErrorClass& eclass){
00649 throw ErrorClass( eclass.errormsg);
00650 }
00651 }
00652
00653
00654 OSnLNode* OSnLNodeMin::cloneOSnLNode(){
00655 OSnLNode *nlNodePoint;
00656 nlNodePoint = new OSnLNodeMin();
00657 return nlNodePoint;
00658 }
00659
00660
00661
00662
00663
00664
00665 OSnLNodeMinus::OSnLNodeMinus()
00666 {
00667 inumberOfChildren = 2;
00668 m_mChildren = new OSnLNode*[2];
00669 m_mChildren[ 0] = NULL;
00670 m_mChildren[ 1] = NULL;
00671 snodeName = "minus";
00672 inodeInt = 1003;
00673 inodeType = 2;
00674 }
00675
00676
00677 OSnLNodeMinus::~OSnLNodeMinus(){
00678 #ifdef DEBUGOSNLNODE
00679 cout << "inside OSnLNodeMinus destructor" << endl;
00680 #endif
00681 for(int i = 0; i < inumberOfChildren; i++){
00682 delete m_mChildren[ i];
00683 m_mChildren[i] = NULL;
00684 }
00685 m_mChildren = NULL;
00686 }
00687
00688 double OSnLNodeMinus::calculateFunction(double *x){
00689 m_dFunctionValue = m_mChildren[0]->calculateFunction( x) - m_mChildren[1]->calculateFunction( x);
00690 return m_dFunctionValue;
00691 }
00692
00693
00694 AD<double> OSnLNodeMinus::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00695 m_CppADTape = m_mChildren[0]->constructCppADTape( cppADIdx, XAD) - m_mChildren[1]->constructCppADTape( cppADIdx, XAD);
00696 return m_CppADTape;
00697 }
00698
00699
00700 OSnLNode* OSnLNodeMinus::cloneOSnLNode(){
00701 OSnLNode *nlNodePoint;
00702 nlNodePoint = new OSnLNodeMinus();
00703 return nlNodePoint;
00704 }
00705
00706
00707
00708
00709
00710
00711
00712 OSnLNodeNegate::OSnLNodeNegate()
00713 {
00714 inumberOfChildren = 1;
00715 m_mChildren = new OSnLNode*[1];
00716 m_mChildren[ 0] = NULL;
00717 snodeName = "negate";
00718 inodeInt = 1004;
00719 inodeType = 1;
00720 }
00721
00722
00723 OSnLNodeNegate::~OSnLNodeNegate(){
00724 #ifdef DEBUGOSNLNODE
00725 cout << "inside OSnLNodeNegate destructor" << endl;
00726 #endif
00727 for(int i = 0; i < inumberOfChildren; i++){
00728 delete m_mChildren[ i];
00729 m_mChildren[i] = NULL;
00730 }
00731 m_mChildren = NULL;
00732 }
00733
00734 double OSnLNodeNegate::calculateFunction(double *x){
00735 m_dFunctionValue = -m_mChildren[0]->calculateFunction( x) ;
00736 return m_dFunctionValue;
00737 }
00738
00739 AD<double> OSnLNodeNegate::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00740 m_CppADTape = -m_mChildren[0]->constructCppADTape( cppADIdx, XAD);
00741 return m_CppADTape;
00742 }
00743
00744
00745 OSnLNode* OSnLNodeNegate::cloneOSnLNode(){
00746 OSnLNode *nlNodePoint;
00747 nlNodePoint = new OSnLNodeNegate();
00748 return nlNodePoint;
00749 }
00750
00751
00752
00753
00754 OSnLNodeTimes::OSnLNodeTimes()
00755 {
00756 inumberOfChildren = 2;
00757 m_mChildren = new OSnLNode*[2];
00758 m_mChildren[ 0] = NULL;
00759 m_mChildren[ 1] = NULL;
00760 snodeName = "times";
00761 inodeInt = 1005;
00762 inodeType = 2;
00763 }
00764
00765
00766 OSnLNodeTimes::~OSnLNodeTimes(){
00767 #ifdef DEBUGOSNLNODE
00768 cout << "inside OSnLNodeTimes destructor" << endl;
00769 #endif
00770 for(int i = 0; i < inumberOfChildren; i++){
00771 delete m_mChildren[ i];
00772 m_mChildren[i] = NULL;
00773 }
00774 m_mChildren = NULL;
00775 }
00776
00777 double OSnLNodeTimes::calculateFunction(double *x){
00778 m_dFunctionValue = m_mChildren[0]->calculateFunction( x)*m_mChildren[1]->calculateFunction( x);
00779 return m_dFunctionValue;
00780 }
00781
00782
00783 AD<double> OSnLNodeTimes::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00784 m_CppADTape = m_mChildren[0]->constructCppADTape( cppADIdx, XAD) * m_mChildren[1]->constructCppADTape( cppADIdx, XAD);
00785 return m_CppADTape;
00786 }
00787
00788 OSnLNode* OSnLNodeTimes::cloneOSnLNode(){
00789 OSnLNode *nlNodePoint;
00790 nlNodePoint = new OSnLNodeTimes();
00791 return nlNodePoint;
00792 }
00793
00794
00795
00796
00797 OSnLNodeDivide::OSnLNodeDivide()
00798 {
00799 inumberOfChildren = 2;
00800 m_mChildren = new OSnLNode*[2];
00801 m_mChildren[ 0] = NULL;
00802 m_mChildren[ 1] = NULL;
00803 snodeName = "divide";
00804 inodeInt = 1006;
00805 inodeType = 2;
00806 }
00807
00808
00809 OSnLNodeDivide::~OSnLNodeDivide(){
00810 #ifdef DEBUGOSNLNODE
00811 cout << "inside OSnLNodeDivide destructor" << endl;
00812 #endif
00813 for(int i = 0; i < inumberOfChildren; i++){
00814 delete m_mChildren[ i];
00815 m_mChildren[i] = NULL;
00816 }
00817 m_mChildren = NULL;
00818 }
00819
00820 double OSnLNodeDivide::calculateFunction(double *x){
00821
00822 m_dFunctionValue = m_mChildren[0]->calculateFunction( x)/m_mChildren[1]->calculateFunction( x);
00823 return m_dFunctionValue;
00824 }
00825
00826
00827 AD<double> OSnLNodeDivide::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00828 m_CppADTape = m_mChildren[0]->constructCppADTape( cppADIdx, XAD) / m_mChildren[1]->constructCppADTape( cppADIdx, XAD);
00829 return m_CppADTape;
00830 }
00831
00832
00833 OSnLNode* OSnLNodeDivide::cloneOSnLNode(){
00834 OSnLNode *nlNodePoint;
00835 nlNodePoint = new OSnLNodeDivide();
00836 return nlNodePoint;
00837 }
00838
00839
00840
00841
00842 OSnLNodePower::OSnLNodePower()
00843 {
00844 inumberOfChildren = 2;
00845 m_mChildren = new OSnLNode*[2];
00846 m_mChildren[ 0] = NULL;
00847 m_mChildren[ 1] = NULL;
00848 snodeName = "power";
00849 inodeInt = 1009;
00850 inodeType = 2;
00851 }
00852
00853
00854 OSnLNodePower::~OSnLNodePower(){
00855 #ifdef DEBUGOSNLNODE
00856 cout << "inside OSnLNodePower destructor" << endl;
00857 #endif
00858 for(int i = 0; i < inumberOfChildren; i++){
00859 delete m_mChildren[ i];
00860 m_mChildren[i] = NULL;
00861 }
00862 m_mChildren = NULL;
00863 }
00864
00865 double OSnLNodePower::calculateFunction(double *x){
00866
00867 m_dFunctionValue = pow(m_mChildren[0]->calculateFunction( x), m_mChildren[1]->calculateFunction( x));
00868 return m_dFunctionValue;
00869 }
00870
00871
00872 AD<double> OSnLNodePower::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00873
00874 if( this->m_mChildren[1]->inodeInt == 5001 ) {
00875 OSnLNodeNumber *numberNode = (OSnLNodeNumber*)m_mChildren[1];
00876
00877 if( (numberNode->value) == int( numberNode->value)){
00878 m_CppADTape = CppAD::pow(m_mChildren[0]->constructCppADTape( cppADIdx, XAD) , int( numberNode->value));
00879 }
00880 else m_CppADTape = CppAD::pow(m_mChildren[0]->constructCppADTape( cppADIdx, XAD) , m_mChildren[1]->constructCppADTape( cppADIdx, XAD) );
00881 }
00882 else{
00883 m_CppADTape = CppAD::pow(m_mChildren[0]->constructCppADTape( cppADIdx, XAD) , m_mChildren[1]->constructCppADTape( cppADIdx, XAD) );
00884 }
00885 return m_CppADTape;
00886 }
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899 OSnLNode* OSnLNodePower::cloneOSnLNode(){
00900 OSnLNode *nlNodePoint;
00901 nlNodePoint = new OSnLNodePower();
00902 return nlNodePoint;
00903 }
00904
00905
00906
00907
00908
00909
00910 OSnLNodeProduct::OSnLNodeProduct()
00911 {
00912 inumberOfChildren = 0;
00913 snodeName = "product";
00914 inodeInt = 1010;
00915 inodeType = -1;
00916 }
00917
00918
00919 OSnLNodeProduct::~OSnLNodeProduct(){
00920 #ifdef DEBUGOSNLNODE
00921 cout << "inside OSnLNodeProduct destructor" << endl;
00922 #endif
00923 if(inumberOfChildren > 0){
00924 for(int i = 0; i < inumberOfChildren; i++){
00925 delete m_mChildren[ i];
00926 m_mChildren[i] = NULL;
00927 }
00928 }
00929 m_mChildren = NULL;
00930 }
00931
00932 double OSnLNodeProduct::calculateFunction(double *x){
00933
00934 m_dFunctionValue = 1.0;
00935 int i;
00936 for(i = 0; i < inumberOfChildren; i++){
00937 m_dFunctionValue = m_dFunctionValue*m_mChildren[i]->calculateFunction(x);
00938 }
00939 return m_dFunctionValue;
00940 }
00941
00942
00943 AD<double> OSnLNodeProduct::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00944 m_CppADTape = 1.0;
00945 int i;
00946 for(i = 0; i < inumberOfChildren; i++){
00947 m_CppADTape = m_CppADTape*m_mChildren[i]->constructCppADTape( cppADIdx, XAD);
00948 }
00949 return m_CppADTape;
00950 }
00951
00952
00953 OSnLNode* OSnLNodeProduct::cloneOSnLNode(){
00954 OSnLNode *nlNodePoint;
00955 nlNodePoint = new OSnLNodeProduct();
00956 return nlNodePoint;
00957 }
00958
00959
00960
00961
00962
00963
00964 OSnLNodeLn::OSnLNodeLn()
00965 {
00966 inumberOfChildren = 1;
00967 m_mChildren = new OSnLNode*[1];
00968 m_mChildren[ 0] = NULL;
00969 snodeName = "ln";
00970 inodeInt = 2007;
00971 inodeType = 1;
00972 }
00973
00974
00975 OSnLNodeLn::~OSnLNodeLn(){
00976 #ifdef DEBUGOSNLNODE
00977 cout << "inside OSnLNodeLn destructor" << endl;
00978 #endif
00979 for(int i = 0; i < inumberOfChildren; i++){
00980 delete m_mChildren[ i];
00981 m_mChildren[i] = NULL;
00982 }
00983 m_mChildren = NULL;
00984 }
00985
00986 double OSnLNodeLn::calculateFunction(double *x){
00987 m_dFunctionValue = log(m_mChildren[0]->calculateFunction( x) );
00988 return m_dFunctionValue;
00989 }
00990
00991
00992 AD<double> OSnLNodeLn::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
00993 m_CppADTape = CppAD::log( m_mChildren[0]->constructCppADTape( cppADIdx, XAD) );
00994 return m_CppADTape;
00995 }
00996
00997 OSnLNode* OSnLNodeLn::cloneOSnLNode(){
00998 OSnLNode *nlNodePoint;
00999 nlNodePoint = new OSnLNodeLn();
01000 return nlNodePoint;
01001 }
01002
01003
01004
01005
01006
01007
01008
01009 OSnLNodeSqrt::OSnLNodeSqrt()
01010 {
01011 inumberOfChildren = 1;
01012 m_mChildren = new OSnLNode*[1];
01013 m_mChildren[ 0] = NULL;
01014 snodeName = "sqrt";
01015 inodeInt = 2006;
01016 inodeType = 1;
01017 }
01018
01019
01020 OSnLNodeSqrt::~OSnLNodeSqrt(){
01021 #ifdef DEBUGOSNLNODE
01022 cout << "inside OSnLNodeSqrt destructor" << endl;
01023 #endif
01024 for(int i = 0; i < inumberOfChildren; i++){
01025 delete m_mChildren[ i];
01026 m_mChildren[i] = NULL;
01027 }
01028 m_mChildren = NULL;
01029 }
01030
01031 double OSnLNodeSqrt::calculateFunction(double *x){
01032 m_dFunctionValue = sqrt(m_mChildren[0]->calculateFunction( x) );
01033 return m_dFunctionValue;
01034 }
01035
01036
01037 AD<double> OSnLNodeSqrt::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
01038 m_CppADTape = CppAD::sqrt( m_mChildren[0]->constructCppADTape( cppADIdx, XAD) );
01039 return m_CppADTape;
01040 }
01041
01042 OSnLNode* OSnLNodeSqrt::cloneOSnLNode(){
01043 OSnLNode *nlNodePoint;
01044 nlNodePoint = new OSnLNodeSqrt();
01045 return nlNodePoint;
01046 }
01047
01048
01049
01050
01051
01052
01053 OSnLNodeSquare::OSnLNodeSquare()
01054 {
01055 inumberOfChildren = 1;
01056 m_mChildren = new OSnLNode*[1];
01057 m_mChildren[ 0] = NULL;
01058 snodeName = "square";
01059 inodeInt = 2005;
01060 inodeType = 1;
01061 }
01062
01063
01064 OSnLNodeSquare::~OSnLNodeSquare(){
01065 #ifdef DEBUGOSNLNODE
01066 cout << "inside OSnLNodeSquare destructor" << endl;
01067 #endif
01068 for(int i = 0; i < inumberOfChildren; i++){
01069 delete m_mChildren[ i];
01070 m_mChildren[i] = NULL;
01071 }
01072 m_mChildren = NULL;
01073 }
01074
01075 double OSnLNodeSquare::calculateFunction(double *x){
01076 m_dFunctionValue = pow( (m_mChildren[0]->calculateFunction( x) ), 2);
01077 return m_dFunctionValue;
01078 }
01079
01080
01081 AD<double> OSnLNodeSquare::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
01082 m_CppADTape = CppAD::pow( m_mChildren[0]->constructCppADTape( cppADIdx, XAD), int( 2) );
01083 return m_CppADTape;
01084 }
01085
01086 OSnLNode* OSnLNodeSquare::cloneOSnLNode(){
01087 OSnLNode *nlNodePoint;
01088 nlNodePoint = new OSnLNodeSquare();
01089 return nlNodePoint;
01090 }
01091
01092
01093
01094
01095 OSnLNodeSin::OSnLNodeSin()
01096 {
01097 inumberOfChildren = 1;
01098 m_mChildren = new OSnLNode*[1];
01099 m_mChildren[ 0] = NULL;
01100 snodeName = "sin";
01101 inodeInt = 3001;
01102 inodeType = 1;
01103 }
01104
01105
01106 OSnLNodeSin::~OSnLNodeSin(){
01107 #ifdef DEBUGOSNLNODE
01108 cout << "inside OSnLNodeSin destructor" << endl;
01109 #endif
01110 for(int i = 0; i < inumberOfChildren; i++){
01111 delete m_mChildren[ i];
01112 m_mChildren[i] = NULL;
01113 }
01114 m_mChildren = NULL;
01115 }
01116
01117 double OSnLNodeSin::calculateFunction(double *x){
01118 m_dFunctionValue = sin(m_mChildren[0]->calculateFunction( x) );
01119 return m_dFunctionValue;
01120 }
01121
01122
01123 AD<double> OSnLNodeSin::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
01124 m_CppADTape = CppAD::sin( m_mChildren[0]->constructCppADTape( cppADIdx, XAD) );
01125 return m_CppADTape;
01126 }
01127
01128 OSnLNode* OSnLNodeSin::cloneOSnLNode(){
01129 OSnLNode *nlNodePoint;
01130 nlNodePoint = new OSnLNodeSin();
01131 return nlNodePoint;
01132 }
01133
01134
01135
01136
01137
01138 OSnLNodeCos::OSnLNodeCos()
01139 {
01140 inumberOfChildren = 1;
01141 m_mChildren = new OSnLNode*[1];
01142 m_mChildren[ 0] = NULL;
01143 snodeName = "cos";
01144 inodeInt = 3002;
01145 inodeType = 1;
01146 }
01147
01148
01149 OSnLNodeCos::~OSnLNodeCos(){
01150 #ifdef DEBUGOSNLNODE
01151 cout << "inside OSnLNodeCos destructor" << endl;
01152 #endif
01153 for(int i = 0; i < inumberOfChildren; i++){
01154 delete m_mChildren[ i];
01155 m_mChildren[i] = NULL;
01156 }
01157 m_mChildren = NULL;
01158 }
01159
01160 double OSnLNodeCos::calculateFunction(double *x){
01161 m_dFunctionValue = cos(m_mChildren[0]->calculateFunction( x) );
01162 return m_dFunctionValue;
01163 }
01164
01165
01166 AD<double> OSnLNodeCos::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
01167 m_CppADTape = CppAD::cos( m_mChildren[0]->constructCppADTape( cppADIdx, XAD) );
01168 return m_CppADTape;
01169 }
01170
01171 OSnLNode* OSnLNodeCos::cloneOSnLNode(){
01172 OSnLNode *nlNodePoint;
01173 nlNodePoint = new OSnLNodeCos();
01174 return nlNodePoint;
01175 }
01176
01177
01178
01179
01180
01181
01182
01183 OSnLNodeExp::OSnLNodeExp()
01184 {
01185 inumberOfChildren = 1;
01186 m_mChildren = new OSnLNode*[1];
01187 m_mChildren[ 0] = NULL;
01188 snodeName = "exp";
01189 inodeInt = 2010;
01190 inodeType = 1;
01191 }
01192
01193
01194 OSnLNodeExp::~OSnLNodeExp(){
01195 #ifdef DEBUGOSNLNODE
01196 cout << "inside OSnLNodeExp destructor" << endl;
01197 #endif
01198 for(int i = 0; i < inumberOfChildren; i++){
01199 delete m_mChildren[ i];
01200 m_mChildren[i] = NULL;
01201 }
01202 m_mChildren = NULL;
01203 }
01204
01205 double OSnLNodeExp::calculateFunction(double *x){
01206 m_dFunctionValue = exp(m_mChildren[0]->calculateFunction( x) );
01207 return m_dFunctionValue;
01208 }
01209
01210
01211 AD<double> OSnLNodeExp::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
01212 m_CppADTape = CppAD::exp( m_mChildren[0]->constructCppADTape( cppADIdx, XAD) );
01213 return m_CppADTape;
01214 }
01215
01216 OSnLNode* OSnLNodeExp::cloneOSnLNode(){
01217 OSnLNode *nlNodePoint;
01218 nlNodePoint = new OSnLNodeExp();
01219 return nlNodePoint;
01220 }
01221
01222
01223
01224
01225
01226
01227
01228 OSnLNodeAbs::OSnLNodeAbs()
01229 {
01230 inumberOfChildren = 1;
01231 m_mChildren = new OSnLNode*[1];
01232 m_mChildren[ 0] = NULL;
01233 snodeName = "abs";
01234 inodeInt = 2001;
01235 inodeType = 1;
01236 }
01237
01238
01239 OSnLNodeAbs::~OSnLNodeAbs(){
01240 #ifdef DEBUGOSNLNODE
01241 cout << "inside OSnLNodeAbs destructor" << endl;
01242 #endif
01243 for(int i = 0; i < inumberOfChildren; i++){
01244 delete m_mChildren[ i];
01245 m_mChildren[i] = NULL;
01246 }
01247 m_mChildren = NULL;
01248 }
01249
01250 double OSnLNodeAbs::calculateFunction(double *x){
01251 m_dFunctionValue = fabs(m_mChildren[0]->calculateFunction( x) );
01252 return m_dFunctionValue;
01253 }
01254
01255
01256 AD<double> OSnLNodeAbs::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
01257 m_CppADTape = CppAD::abs( m_mChildren[0]->constructCppADTape( cppADIdx, XAD) );
01258 return m_CppADTape;
01259 }
01260
01261 OSnLNode* OSnLNodeAbs::cloneOSnLNode(){
01262 OSnLNode *nlNodePoint;
01263 nlNodePoint = new OSnLNodeAbs();
01264 return nlNodePoint;
01265 }
01266
01267
01268
01269
01270
01271
01272 OSnLNodeIf::OSnLNodeIf()
01273 {
01274 inumberOfChildren = 3;
01275 m_mChildren = new OSnLNode*[3];
01276 m_mChildren[ 0] = NULL;
01277 m_mChildren[ 1] = NULL;
01278 m_mChildren[ 2] = NULL;
01279 snodeName = "if";
01280 inodeInt = 7001;
01281 inodeType = 3;
01282 }
01283
01284
01285 OSnLNodeIf::~OSnLNodeIf(){
01286 #ifdef DEBUGOSNLNODE
01287 cout << "inside OSnLNodeIf destructor" << endl;
01288 #endif
01289 for(int i = 0; i < inumberOfChildren; i++){
01290 delete m_mChildren[ i];
01291 m_mChildren[i] = NULL;
01292 }
01293 m_mChildren = NULL;
01294 }
01295
01296 double OSnLNodeIf::calculateFunction(double *x){
01297 if(m_mChildren[0]->calculateFunction( x) >= 0) m_dFunctionValue = m_mChildren[ 1]->calculateFunction( x);
01298 else m_dFunctionValue = m_mChildren[ 2]->calculateFunction( x);
01299 return m_dFunctionValue;
01300 }
01301
01302 AD<double> OSnLNodeIf::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
01303
01304 try{
01305 throw ErrorClass("if operator not supported by current Algorithmic Differentiation implementation");
01306 return m_CppADTape;
01307 }
01308 catch(const ErrorClass& eclass){
01309 throw ErrorClass( eclass.errormsg);
01310 }
01311 }
01312
01313 OSnLNode* OSnLNodeIf::cloneOSnLNode(){
01314 OSnLNode *nlNodePoint;
01315 nlNodePoint = new OSnLNodeIf();
01316 return nlNodePoint;
01317 }
01318
01319
01320
01321
01322
01323 OSnLNodeNumber::OSnLNodeNumber()
01324 {
01325 inodeInt = 5001;
01326 inumberOfChildren = 0;
01327 m_mChildren = NULL;
01328 snodeName = "number";
01329 inodeType = 0;
01330 value = 0.0;
01331 type = "real";
01332 id = "";
01333
01334 }
01335
01336 OSnLNodeNumber::~OSnLNodeNumber(){
01337 #ifdef DEBUGOSNLNODE
01338 cout << "inside OSnLNodeNumber destructor" << endl;
01339 #endif
01340 m_mChildren = NULL;
01341 }
01342
01343
01344 std::string OSnLNodeNumber::getTokenNumber(){
01345 ostringstream outStr;
01346 outStr << inodeInt;
01347 outStr << ":" ;
01348 outStr << value ;
01349
01350 outStr << ":" ;
01351 outStr << type ;
01352
01353
01354 outStr << ":" ;
01355 outStr << id;
01356
01357 return outStr.str();
01358 }
01359
01360
01361 std::string OSnLNodeNumber::getTokenName(){
01362 ostringstream outStr;
01363 outStr << snodeName;
01364 outStr << ":" ;
01365 outStr << value ;
01366
01367 outStr << ":" ;
01368 outStr << type ;
01369
01370
01371 outStr << ":" ;
01372 outStr << id;
01373
01374 return outStr.str();
01375 }
01376
01377
01378 std::string OSnLNodeNumber::getNonlinearExpressionInXML(){
01379 ostringstream outStr;
01380 outStr << "<" ;
01381 outStr << snodeName;
01382 outStr << " value=\"";
01383 outStr << value ;
01384 outStr << "\"";
01385 outStr << " type=\"";
01386 outStr << type ;
01387 outStr << "\"";
01388 if(id.length() > 0){
01389 outStr << " id=\"";
01390 outStr << id ;
01391 outStr << "\"";
01392 }
01393 outStr << "/>";
01394 return outStr.str();
01395 }
01396
01397
01398 double OSnLNodeNumber::calculateFunction(double *x){
01399 m_dFunctionValue = this->value;
01400 return m_dFunctionValue;
01401 }
01402
01403 AD<double> OSnLNodeNumber::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
01404 m_CppADTape = this->value;
01405 return m_CppADTape;
01406 }
01407
01408 OSnLNode* OSnLNodeNumber::cloneOSnLNode(){
01409 OSnLNode *nlNodePoint;
01410 nlNodePoint = new OSnLNodeNumber();
01411 return nlNodePoint;
01412 }
01413
01414
01415
01416
01417 OSnLNodeE::OSnLNodeE()
01418 {
01419 inodeInt = 5004;
01420 inumberOfChildren = 0;
01421 m_mChildren = NULL;
01422 snodeName = "E";
01423 inodeType = 0;
01424
01425
01426
01427
01428 }
01429
01430 OSnLNodeE::~OSnLNodeE(){
01431 #ifdef DEBUGOSNLNODE
01432 cout << "inside OSnLNodeE destructor" << endl;
01433 #endif
01434 m_mChildren = NULL;
01435 }
01436
01437
01438 std::string OSnLNodeE::getTokenNumber(){
01439 ostringstream outStr;
01440 outStr << inodeInt;
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451 return outStr.str();
01452 }
01453
01454
01455 std::string OSnLNodeE::getTokenName(){
01456 ostringstream outStr;
01457 outStr << snodeName;
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468 return outStr.str();
01469 }
01470
01471
01472 std::string OSnLNodeE::getNonlinearExpressionInXML(){
01473 ostringstream outStr;
01474 outStr << "<" ;
01475 outStr << snodeName;
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487 outStr << "/>";
01488 return outStr.str();
01489 }
01490
01491
01492 double OSnLNodeE::calculateFunction(double *x){
01493 m_dFunctionValue = OS_E_VALUE;
01494 return m_dFunctionValue;
01495 }
01496
01497 AD<double> OSnLNodeE::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
01498 m_CppADTape = OS_E_VALUE;
01499 return m_CppADTape;
01500 }
01501
01502 OSnLNode* OSnLNodeE::cloneOSnLNode(){
01503 OSnLNode *nlNodePoint;
01504 nlNodePoint = new OSnLNodeE();
01505 return nlNodePoint;
01506 }
01507
01508
01509
01510
01511
01512 OSnLNodePI::OSnLNodePI()
01513 {
01514 inodeInt = 5003;
01515 inumberOfChildren = 0;
01516 m_mChildren = NULL;
01517 snodeName = "PI";
01518 inodeType = 0;
01519
01520
01521 }
01522
01523
01524 OSnLNodePI::~OSnLNodePI(){
01525 #ifdef DEBUGOSNLNODE
01526 cout << "inside OSnLNodePI destructor" << endl;
01527 #endif
01528 m_mChildren = NULL;
01529 }
01530
01531
01532 std::string OSnLNodePI::getTokenNumber(){
01533 ostringstream outStr;
01534 outStr << inodeInt;
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545 return outStr.str();
01546 }
01547
01548
01549 std::string OSnLNodePI::getTokenName(){
01550 ostringstream outStr;
01551 outStr << snodeName;
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562 return outStr.str();
01563 }
01564
01565
01566 std::string OSnLNodePI::getNonlinearExpressionInXML(){
01567 ostringstream outStr;
01568 outStr << "<" ;
01569 outStr << snodeName;
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581 outStr << "/>";
01582 return outStr.str();
01583 }
01584
01585
01586 double OSnLNodePI::calculateFunction(double *x){
01587 m_dFunctionValue = OS_PI_VALUE;
01588 return m_dFunctionValue;
01589 }
01590
01591 AD<double> OSnLNodePI::constructCppADTape(std::map<int, int> *cppADIdx, CppAD::vector< AD<double> > *XAD){
01592 m_CppADTape = OS_PI_VALUE;
01593 return m_CppADTape;
01594 }
01595
01596 OSnLNode* OSnLNodePI::cloneOSnLNode(){
01597 OSnLNode *nlNodePoint;
01598 nlNodePoint = new OSnLNodePI();
01599 return nlNodePoint;
01600 }
01601
01602
01603
01604
01605 OSnLNodeVariable::OSnLNodeVariable()
01606 {
01607 inumberOfChildren = 0;
01608 m_mChildren = NULL;
01609 snodeName = "variable";
01610 inodeInt = 6001;
01611 inodeType = -1;
01612 coef = 1.0;
01613 idx = -1;
01614 }
01615
01616 OSnLNodeVariable::~OSnLNodeVariable(){
01617 #ifdef DEBUGOSNLNODE
01618 cout << "inside OSnLNodeVariable destructor" << endl;
01619 cout << "number kids = " << inumberOfChildren << endl;
01620 #endif
01621 if(inumberOfChildren > 0){
01622 for(int i = 0; i < inumberOfChildren; i++){
01623 delete m_mChildren[ i];
01624 m_mChildren[i] = NULL;
01625 }
01626 }
01627 m_mChildren = NULL;
01628 }
01629
01630
01631 std::string OSnLNodeVariable::getTokenNumber(){
01632 ostringstream outStr;
01633
01634 outStr << inodeInt;
01635 outStr << "[";
01636 outStr << inumberOfChildren ;
01637 outStr << "]";
01638 outStr << ":" ;
01639 outStr << idx;
01640 outStr << ":" ;
01641 outStr << coef;
01642 outStr << ":real:" ;
01643 return outStr.str();
01644 }
01645
01646
01647 std::string OSnLNodeVariable::getTokenName(){
01648 ostringstream outStr;
01649
01650 outStr << snodeName;
01651 outStr << "[";
01652 outStr << inumberOfChildren ;
01653 outStr << "]";
01654 outStr << ":" ;
01655 outStr << idx;
01656 outStr << ":" ;
01657 outStr << coef;
01658 outStr << ":real:" ;
01659 return outStr.str();
01660 }
01661
01662
01663 std::string OSnLNodeVariable::getNonlinearExpressionInXML(){
01664 ostringstream outStr;
01665 outStr << "<" ;
01666 outStr << snodeName;
01667 outStr << " idx=\"";
01668 outStr << idx ;
01669 outStr << "\"";
01670 outStr << " coef=\"";
01671 outStr << coef ;
01672 outStr << "\"";
01673 if(inumberOfChildren > 0) {
01674 outStr << ">";
01675 }
01676 else{
01677 outStr << "/>";
01678 }
01679 if(inumberOfChildren > 0){
01680 for(int i = 0; i < inumberOfChildren; i++){
01681 outStr << m_mChildren[i]->getNonlinearExpressionInXML();
01682 }
01683 }
01684 if(inumberOfChildren > 0) {
01685 outStr << "</" ;
01686 outStr << snodeName ;
01687 outStr << ">" ;
01688 }
01689 return outStr.str();
01690 }
01691
01692 double OSnLNodeVariable::calculateFunction(double *x){
01693 m_dFunctionValue = coef*x[idx];
01694 return m_dFunctionValue;
01695 }
01696
01697 AD<double> OSnLNodeVariable::constructCppADTape(std::map<int, int> *varIdx, CppAD::vector< AD<double> > *XAD){
01698 m_CppADTape = coef;
01699
01700
01701
01702
01703 m_CppADTape = coef*(*XAD)[ (*varIdx)[ idx] ];
01704 return m_CppADTape;
01705 }
01706
01707
01708 void OSnLNodeVariable::getVariableIndexMap(std::map<int, int> *varIdx){
01709 int numVars;
01710 if( (*varIdx).find( idx) != (*varIdx).end() ){
01711
01712 }
01713 else{
01714
01715 numVars = (*varIdx).size();
01716
01717 (*varIdx)[ idx] = numVars;
01718 }
01719
01720 }
01721
01722
01723 OSnLNode* OSnLNodeVariable::cloneOSnLNode(){
01724 OSnLNode *nlNodePoint;
01725 nlNodePoint = new OSnLNodeVariable();
01726 return nlNodePoint;
01727 }
01728
01729
01730
01731
01732
01733
01734