Changeset 3263cf5 in tol
- Timestamp:
- Oct 21, 2008, 11:04:48 AM (18 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- e3f5af6
- Parents:
- 3c7e287
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/dynhlm/_db_api.tools.modses.mix.tol
r3c7e287 r3263cf5 158 158 Eval("ModSes.Mix.OrderRelation.Create.ok=ok") 159 159 }; 160 161 ////////////////////////////////////////////////////////////////////////////// 162 Text _.autodoc.member.ModSes.Mix.Constraint.Create = 163 "Inserts a new arbitrary constraint 164 165 leftBound <= linComb[1] + ··· + linComb[k] <= rightBound 166 167 where 168 leftBound could be -1/0 or ? if there are no lower limit 169 rightBound could be +1/0 or ? if there are no upper limit 170 Each element of linComb is a NameBlock like this 171 [[ 172 Text _.id_node; 173 Text _.id_parameter; 174 Real _.coef 175 ]] 176 177 Example: In order to insert this inequation 178 179 3.5*nodo1::beta2 -2.1*nodo2::beta5 <= 7.1*nodo1::beta3 180 181 Syntax could be 182 183 Real { ModSes.Mix.Constraint.Create( 184 my_dbName, my_model,my_session, 185 Real leftBound = -1/0, 186 Set linComb = SetOfNameBlock 187 ([[ 188 Text _.id_node = \"nodo1\"; 189 Text _.id_parameter = \"beta2\"; 190 Real _.coef = 3.5 191 ]],[[ 192 Text _.id_node = \"nodo2\"; 193 Text _.id_parameter = \"beta5\"; 194 Real _.coef = -2.1 195 ]],[[ 196 Text _.id_node = \"nodo1\"; 197 Text _.id_parameter = \"beta3\"; 198 Real _.coef = -7.1 199 ]]), 200 Real rightBound = 0)}; 201 "; 202 Real ModSes.Mix.Constraint.Create(Text dbName, 203 Text model, 204 Text session, 205 Real leftBound, 206 Set linComb, 207 Real rightBound) 208 ////////////////////////////////////////////////////////////////////////////// 209 { 210 NameBlock _table = BysMcmc::Bsr::DynHlm::DBApi::_.table; 211 Real numInequation = 212 { 213 Real aux = BysMcmc::Bsr::DynHlm::DBApi::SqlTableTrace( 214 "SELECT max(nu_inequation) FROM "+dbName+"."+_table::ConstrBorder+"\n" 215 "WHERE id_model='"+model+"' AND\n" 216 " id_session='"+session+"';","")[1][1]; 217 If(IsUnknown(aux),1,aux+1) 218 }; 219 Set nodes = Classify(linComb,Real(NameBlock a, NameBlock b) 220 { 221 Compare(a::_.id_node, b::_.id_node) 222 }); 223 Text id_node = If(Card(nodes)==1, (linComb[1])::_.id_node, 224 { 225 Real If(Not(BysMcmc::Bsr::DynHlm::DBApi::SqlTableTrace( 226 "SELECT count(*) FROM "+dbName+"."+_table::Node+"\n" 227 "WHERE id_model='"+model+"' AND\n" 228 " id_session='"+session+"' AND\n" 229 " id_node='MIXTURE';","")[1][1]), 230 { 231 Real BysMcmc::Bsr::DynHlm::DBApi::SqlExecTrace( 232 "INSERT INTO "+_table::Node+"\n" 233 "VALUES('"+model+"','"+session+"','MIXTURE','MIX',999999999,-1,'')\n") 234 }); 235 "MIXTURE" 236 }); 237 Real ok.1 = BysMcmc::Bsr::DynHlm::DBApi::SqlExecTrace( 238 "INSERT INTO "+dbName+"."+_table::ConstrBorder+"\n"+ 239 "VALUES('"+model+"','"+session+"',"+ 240 IntText(numInequation)+","+ 241 "'"+id_node+"',"+ 242 BysMcmc::Bsr::DynHlm::DBApi::SqlFormatReal(leftBound)+","+ 243 BysMcmc::Bsr::DynHlm::DBApi::SqlFormatReal(rightBound)+");"); 244 Real ok.2 = SetMin(EvalSet(linComb, Real(NameBlock a) 245 { 246 BysMcmc::Bsr::DynHlm::DBApi::SqlExecTrace( 247 "INSERT INTO "+dbName+"."+_table::ConstrLinComb+"\n"+ 248 "VALUES('"+model+"','"+session+"',"+ 249 IntText(numInequation)+","+ 250 "'"+a::_.id_node+"',"+ 251 "'"+a::_.id_parameter+"',"+ 252 BysMcmc::Bsr::DynHlm::DBApi::SqlFormatReal(a::_.coef)+");") 253 })); 254 Eval("ModSes.Mix.Constraint.Create.ok=ok.1 & ok.2") 255 }; 256 PutDescription(_.autodoc.member.ModSes.Mix.Constraint.Create, 257 ModSes.Mix.Constraint.Create);
Note: See TracChangeset
for help on using the changeset viewer.
