| 98 | void resetTime() { curtime = -1; } |
| 99 | |
| 100 | //! check if model and losses is correct and consistent |
| 101 | virtual void validate(){ |
| 102 | /* |
| 103 | RV:findself hleda cela rv jako vektory, pri nenalezeni je -1 |
| 104 | RV:dataind hleda datove slozky, tedy indexy v poli skalaru, pri nenalezeni vynecha |
| 105 | */ |
| 106 | // (0) nonempty |
| 107 | bdm_assert((Models.size() > 0), "VALIDATION FAILED! Models array empty."); |
| 108 | bdm_assert((Losses.size() > 0), "VALIDATION FAILED! Losses array empty."); |
| 109 | if( (Models.size() <= 0) || (Losses.size() <= 0) ) return; |
| 110 | |
| 111 | // (1) test Models array rv - acceptable rv is only part/composition of LQG_universal::rv, LQG_universal::rvc and const 1 |
| 112 | RV accept_total; |
| 113 | accept_total = rv; |
| 114 | accept_total.add(rvc); |
| 115 | accept_total.add(RV("1", 1, 0)); |
| 116 | |
| 117 | int i, j; |
| 118 | ivec finding1; |
| 119 | |
| 120 | for(i = 0; i < Models.length(); i++){ |
| 121 | finding1 = Models(i).rv.findself(accept_total); |
| 122 | |
| 123 | bdm_assert( !(STRICT_RV && (finding1.size() <= 0)), "VALIDATION FAILED! Empty RV used."); |
| 124 | |
| 125 | for(j = 0; j < finding1.size(); j++){ |
| 126 | bdm_assert( ( finding1(j) > (-1) ), "VALIDATION FAILED! Provided input RV for some Models function is unknown, forbidden or recursive."); |
| 127 | if(finding1(j) <= (-1) ) return; //rv element is not part of admissible rvs => error |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | //NOT!!! (2) test Models array rv_ret - each array element's rv_ret must be unique (except const 1) |
| 132 | //RV unique_rv_ret; |
| 133 | //unique_rv_ret = Models(0).rv_ret; |
| 134 | |
| 135 | //for(i = 1; i < Models.length(); i++){ |
| 136 | // finding1 = Models(i).rv_ret.findself(unique_rv_ret); |
| 137 | |
| 138 | // for(j = 0; j < finding1.size(); j++){ |
| 139 | // if(Models(i).rv_ret.name(j) == "1") continue; // except const 1 |
| 140 | |
| 141 | // bdm_assert((finding1(j) == (-1) ), "VALIDATION FAILED! Models functions result RV (rv_ret) must be unique."); |
| 142 | // if(finding1(j) != (-1) ) return; //rv_ret element not unique |
| 143 | // } |
| 144 | |
| 145 | // unique_rv_ret.add(Models(i).rv_ret); |
| 146 | //} |
| 147 | |
| 148 | // (3) test Losses array - acceptable rv is only part/composition of LQG_universal::rv, LQG_universal::rvc, Models rv_ret and const 1 |
| 149 | for(i = 0; i < Models.length(); i++) accept_total.add(Models(i).rv_ret); //old accept_total from (1) + all rv_ret from Models |
| 150 | |
| 151 | for(i = 0; i < Losses.length(); i++){ |
| 152 | finding1 = Losses(i).rv.findself(accept_total); |
| 153 | |
| 154 | bdm_assert( !(STRICT_RV && (finding1.size() <= 0)), "VALIDATION FAILED! Empty RV used."); |
| 155 | |
| 156 | for(j = 0; j < finding1.size(); j++){ |
| 157 | bdm_assert( ( finding1(j) > (-1) ), "VALIDATION FAILED! Unacceptable RV used in some Losses function."); |
| 158 | if(finding1(j) <= (-1) ) return; //rv element is not part of admissible rvs => error |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // same for finalLoss |
| 163 | finding1 = finalLoss.rv.findself(accept_total); |
| 164 | |
| 165 | bdm_assert( !(STRICT_RV && (finding1.size() <= 0)), "VALIDATION FAILED! Empty RV used."); |
| 166 | |
| 167 | for(j = 0; j < finding1.size(); j++){ |
| 168 | bdm_assert( ( finding1(j) > (-1) ), "VALIDATION FAILED! Unacceptable RV used in finalLoss function."); |
| 169 | if(finding1(j) <= (-1) ) return; //rv element is not part of admissible rvs => error |
| 170 | } |
| 171 | } |
| 172 | |