1.1 --- a/src/java-tests/isac/bridge/TestBridge.java Fri Mar 11 04:48:03 2005 +0100
1.2 +++ b/src/java-tests/isac/bridge/TestBridge.java Fri Mar 11 10:46:31 2005 +0100
1.3 @@ -45,148 +45,148 @@
1.4
1.5 static Logger logger_ = Logger.getLogger(MathEngine.class.getName());
1.6
1.7 - /**
1.8 - * tests the example 'IsacCore/Tests/minipbl_with_mini-subpbl' comprising
1.9 - UC
1.10 - * 'start auto calculation' \label{SPECIFY:START:auto}
1.11 - *
1.12 - * see BridgeLog (sml <->java) in UC-mini-auto-step.txt
1.13 - */
1.14 - public void testMinisubpblAutoCalc() throws Exception {
1.15 - System.out
1.16 - .println("---BEGIN isac.bridge.TestBridge#testMinisubpblAutoCalc");
1.17 -
1.18 - //prepare Formalization for start calculation in step_b
1.19 - Formalization fmzA = null, fmz = null;
1.20 - Object test = null;
1.21 - // the following would be instead reading from file ...
1.22 - //KEStoreServices ks = new
1.23 - //KEStoreServices("isac/src/java-tests/isac/kestore/data");
1.24 - //Vector vec = ks.loadContent("exp", "exp_IsacCore_Tests_1b.xml");
1.25 - //String xmlstr = (String) vec.firstElement();
1.26 - //
1.27 - //FormalizationDigest fd = new FormalizationDigest();
1.28 - //fmz = fd.parseFormalization((String) xmlstr);
1.29 - //
1.30 - File fAbroad = new File("isac/src/java-tests/isac/util/parser/data",
1.31 - "exp_IsacCore_Tests_1b.fmz");
1.32 - File f = new File(
1.33 - "isac/src/java-tests/isac/bridge/data/mini-auto-step",
1.34 - "step_a.fmz");
1.35 - try {
1.36 - ObjectInputStream oisA = new ObjectInputStream(new FileInputStream(
1.37 - fAbroad));
1.38 - ObjectInputStream ois = new ObjectInputStream(
1.39 - new FileInputStream(f));
1.40 - fmzA = (Formalization) oisA.readObject();
1.41 - fmz = (Formalization) ois.readObject();
1.42 - oisA.close();
1.43 - ois.close();
1.44 - } catch (IOException e) {
1.45 - e.printStackTrace();
1.46 - } catch (ClassNotFoundException e) {
1.47 - e.printStackTrace();
1.48 - }
1.49 - System.out.println(".FormalizationDigest.parseFormalization");
1.50 - //System.out.println("-fmz.toString()" + fmz.toString());
1.51 - assertEquals("mini-auto: fmz from 'abroad' file ", fmzA.toSMLString(),
1.52 - fmz.toSMLString());
1.53 - System.out.println(".end step_a-----");
1.54 - //end step_a ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.55 -
1.56 - //start calculation and complete CalcHead
1.57 - MathEngine.init("localhost");
1.58 - MathEngine me = MathEngine.getMathEngine();
1.59 - IToCalc ct = me.startCalculation(fmz);
1.60 - // sent to bridge: CalcTree [(["equality (x+1=2)", "sol ...
1.61 - // sent to bridge: Iterator 1; #drop: make It.1 in CalcTree
1.62 - // sent to bridge: moveActiveRoot 1; #drop: make It.1 in CalcTree
1.63 -
1.64 - IToUser user = new MockIToUser();
1.65 - ct.addDataChangeListener(user);
1.66 - CalcChangedEvent cce = null;
1.67 -
1.68 - ct.completeCalcHead();// ######informListeners NOW!!!
1.69 - // sent to bridge: autoCalculate 1 CompleteCalcHead;
1.70 - ICalcIterator ci = ct.getActiveFormula();
1.71 - //######^^^ drop: push addDataChangeListener towards/into
1.72 - //######^^^ startCalculation and fetch ci from CalcChanged:
1.73 - //ci = (ICalcIterator) cce.getLastGeneratedFormula().clone();
1.74 - CalcHead ch = (CalcHead) ci.getFormula();
1.75 -
1.76 - // too sensible against changes in CalcHead !!!
1.77 - // f = new File("isac/src/java-tests/isac/bridge/data/mini-auto-step",
1.78 - // "step_b.calcHead");
1.79 - // //try {
1.80 - // // ObjectOutputStream oos = new ObjectOutputStream(
1.81 - // // new FileOutputStream(f));
1.82 - // // oos.writeObject(ch);
1.83 - // // oos.close();
1.84 - // //} catch (IOException e) {
1.85 - // // e.printStackTrace();
1.86 - // //}
1.87 - // try {
1.88 - // ObjectInputStream ois = new ObjectInputStream(
1.89 - // new FileInputStream(f));
1.90 - // test = (CalcHead) ois.readObject();
1.91 - // ois.close();
1.92 - // } catch (IOException e) {
1.93 - // e.printStackTrace();
1.94 - // } catch (ClassNotFoundException e) {
1.95 - // e.printStackTrace();
1.96 - // }
1.97 - // System.out.println(".calchead: " + ch.toSMLString());
1.98 - // assertEquals("mini-auto: calcHead", ch.toSMLString(), ((CalcHead) test)
1.99 - // .toSMLString());
1.100 - System.out.println(".end step_b-----");
1.101 - //end step_b
1.102 - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.103 -
1.104 - //autoCalculate
1.105 - System.out.println(".autoCalculate");
1.106 - ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.107 -
1.108 - cce = ((MockIToUser) user).getCalcChangedEvent();
1.109 - assertEquals("unchanged", cce.getLastUnchangedFormula().toSMLString(),
1.110 - "([],Met)");
1.111 - assertEquals("deleted", cce.getLastDeletedFormula().toSMLString(),
1.112 - "([],Met)");
1.113 - assertEquals("generated", cce.getLastGeneratedFormula().toSMLString(),
1.114 - "([],Res)");
1.115 - System.out.println(".end step_c-----");
1.116 - //end step_c
1.117 - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.118 -
1.119 - //display the steps generated
1.120 - Object fch = null;
1.121 - ci = (ICalcIterator) cce.getLastUnchangedFormula().clone();
1.122 - int i = 0;
1.123 - // while (ci.compareTo(cce.getLastGeneratedFormula()) < 0) {
1.124 - // i++;
1.125 - // boolean b = ci.moveDown();
1.126 - // System.out.print("..iterator at " + ci.toSMLString());
1.127 - // fch = ci.getFormula();
1.128 - // System.out.println(" yields "
1.129 - // + ((ICalcElement) fch).toSMLString());
1.130 - // }
1.131 - Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.132 - cce.getLastGeneratedFormula(), new Integer(2), false);
1.133 - for (i=0; i<elems.size(); i++) {
1.134 - System.out.println(" yields "
1.135 - + ((ICalcElement) elems.elementAt(i)).toSMLString());
1.136 - }
1.137 - System.out.println("mini-auto: steps= " + i);
1.138 - assertEquals("mini-auto: steps= ",i,10);
1.139 - assertEquals("mini-auto: last step",
1.140 - ((ICalcElement) elems.elementAt(i-1)).toSMLString(), "[x = 1]");
1.141 - System.out.println(".end step_d-----");
1.142 - //end step_d
1.143 - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.144 -
1.145 - logger_.debug("---END isac.bridge.TestBridge#testMinisubpblAutoCalc");
1.146 - System.out
1.147 - .println("---END isac.bridge.TestBridge#testMinisubpblAutoCalc");
1.148 - }
1.149 +// /**
1.150 +// * tests the example 'IsacCore/Tests/minipbl_with_mini-subpbl' comprising
1.151 +// UC
1.152 +// * 'start auto calculation' \label{SPECIFY:START:auto}
1.153 +// *
1.154 +// * see BridgeLog (sml <->java) in UC-mini-auto-step.txt
1.155 +// */
1.156 +// public void testMinisubpblAutoCalc() throws Exception {
1.157 +// System.out
1.158 +// .println("---BEGIN isac.bridge.TestBridge#testMinisubpblAutoCalc");
1.159 +//
1.160 +// //prepare Formalization for start calculation in step_b
1.161 +// Formalization fmzA = null, fmz = null;
1.162 +// Object test = null;
1.163 +// // the following would be instead reading from file ...
1.164 +// //KEStoreServices ks = new
1.165 +// //KEStoreServices("isac/src/java-tests/isac/kestore/data");
1.166 +// //Vector vec = ks.loadContent("exp", "exp_IsacCore_Tests_1b.xml");
1.167 +// //String xmlstr = (String) vec.firstElement();
1.168 +// //
1.169 +// //FormalizationDigest fd = new FormalizationDigest();
1.170 +// //fmz = fd.parseFormalization((String) xmlstr);
1.171 +// //
1.172 +// File fAbroad = new File("isac/src/java-tests/isac/util/parser/data",
1.173 +// "exp_IsacCore_Tests_1b.fmz");
1.174 +// File f = new File(
1.175 +// "isac/src/java-tests/isac/bridge/data/mini-auto-step",
1.176 +// "step_a.fmz");
1.177 +// try {
1.178 +// ObjectInputStream oisA = new ObjectInputStream(new FileInputStream(
1.179 +// fAbroad));
1.180 +// ObjectInputStream ois = new ObjectInputStream(
1.181 +// new FileInputStream(f));
1.182 +// fmzA = (Formalization) oisA.readObject();
1.183 +// fmz = (Formalization) ois.readObject();
1.184 +// oisA.close();
1.185 +// ois.close();
1.186 +// } catch (IOException e) {
1.187 +// e.printStackTrace();
1.188 +// } catch (ClassNotFoundException e) {
1.189 +// e.printStackTrace();
1.190 +// }
1.191 +// System.out.println(".FormalizationDigest.parseFormalization");
1.192 +// //System.out.println("-fmz.toString()" + fmz.toString());
1.193 +// assertEquals("mini-auto: fmz from 'abroad' file ", fmzA.toSMLString(),
1.194 +// fmz.toSMLString());
1.195 +// System.out.println(".end step_a-----");
1.196 +// //end step_a ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.197 +//
1.198 +// //start calculation and complete CalcHead
1.199 +// MathEngine.init("localhost");
1.200 +// MathEngine me = MathEngine.getMathEngine();
1.201 +// IToCalc ct = me.startCalculation(fmz);
1.202 +// // sent to bridge: CalcTree [(["equality (x+1=2)", "sol ...
1.203 +// // sent to bridge: Iterator 1; #drop: make It.1 in CalcTree
1.204 +// // sent to bridge: moveActiveRoot 1; #drop: make It.1 in CalcTree
1.205 +//
1.206 +// IToUser user = new MockIToUser();
1.207 +// ct.addDataChangeListener(user);
1.208 +// CalcChangedEvent cce = null;
1.209 +//
1.210 +// ct.completeCalcHead();// ######informListeners NOW!!!
1.211 +// // sent to bridge: autoCalculate 1 CompleteCalcHead;
1.212 +// ICalcIterator ci = ct.getActiveFormula();
1.213 +// //######^^^ drop: push addDataChangeListener towards/into
1.214 +// //######^^^ startCalculation and fetch ci from CalcChanged:
1.215 +// //ci = (ICalcIterator) cce.getLastGeneratedFormula().clone();
1.216 +// CalcHead ch = (CalcHead) ci.getFormula();
1.217 +//
1.218 +// // too sensible against changes in CalcHead !!!
1.219 +// // f = new File("isac/src/java-tests/isac/bridge/data/mini-auto-step",
1.220 +// // "step_b.calcHead");
1.221 +// // //try {
1.222 +// // // ObjectOutputStream oos = new ObjectOutputStream(
1.223 +// // // new FileOutputStream(f));
1.224 +// // // oos.writeObject(ch);
1.225 +// // // oos.close();
1.226 +// // //} catch (IOException e) {
1.227 +// // // e.printStackTrace();
1.228 +// // //}
1.229 +// // try {
1.230 +// // ObjectInputStream ois = new ObjectInputStream(
1.231 +// // new FileInputStream(f));
1.232 +// // test = (CalcHead) ois.readObject();
1.233 +// // ois.close();
1.234 +// // } catch (IOException e) {
1.235 +// // e.printStackTrace();
1.236 +// // } catch (ClassNotFoundException e) {
1.237 +// // e.printStackTrace();
1.238 +// // }
1.239 +// // System.out.println(".calchead: " + ch.toSMLString());
1.240 +// // assertEquals("mini-auto: calcHead", ch.toSMLString(), ((CalcHead) test)
1.241 +// // .toSMLString());
1.242 +// System.out.println(".end step_b-----");
1.243 +// //end step_b
1.244 +// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.245 +//
1.246 +// //autoCalculate
1.247 +// System.out.println(".autoCalculate");
1.248 +// ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.249 +//
1.250 +// cce = ((MockIToUser) user).getCalcChangedEvent();
1.251 +// assertEquals("unchanged", cce.getLastUnchangedFormula().toSMLString(),
1.252 +// "([],Met)");
1.253 +// assertEquals("deleted", cce.getLastDeletedFormula().toSMLString(),
1.254 +// "([],Met)");
1.255 +// assertEquals("generated", cce.getLastGeneratedFormula().toSMLString(),
1.256 +// "([],Res)");
1.257 +// System.out.println(".end step_c-----");
1.258 +// //end step_c
1.259 +// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.260 +//
1.261 +// //display the steps generated
1.262 +// Object fch = null;
1.263 +// ci = (ICalcIterator) cce.getLastUnchangedFormula().clone();
1.264 +// int i = 0;
1.265 +// // while (ci.compareTo(cce.getLastGeneratedFormula()) < 0) {
1.266 +// // i++;
1.267 +// // boolean b = ci.moveDown();
1.268 +// // System.out.print("..iterator at " + ci.toSMLString());
1.269 +// // fch = ci.getFormula();
1.270 +// // System.out.println(" yields "
1.271 +// // + ((ICalcElement) fch).toSMLString());
1.272 +// // }
1.273 +// Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.274 +// cce.getLastGeneratedFormula(), new Integer(2), false);
1.275 +// for (i=0; i<elems.size(); i++) {
1.276 +// System.out.println(" yields "
1.277 +// + ((ICalcElement) elems.elementAt(i)).toSMLString());
1.278 +// }
1.279 +// System.out.println("mini-auto: steps= " + i);
1.280 +// assertEquals("mini-auto: steps= ",i,10);
1.281 +// assertEquals("mini-auto: last step",
1.282 +// ((ICalcElement) elems.elementAt(i-1)).toSMLString(), "[x = 1]");
1.283 +// System.out.println(".end step_d-----");
1.284 +// //end step_d
1.285 +// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.286 +//
1.287 +// logger_.debug("---END isac.bridge.TestBridge#testMinisubpblAutoCalc");
1.288 +// System.out
1.289 +// .println("---END isac.bridge.TestBridge#testMinisubpblAutoCalc");
1.290 +// }
1.291
1.292 /***************************************************************************
1.293 * tests the example 'IsacCore/Tests/minipbl_with_mini-subpbl' comprising
1.294 @@ -233,22 +233,6 @@
1.295 ICalcIterator ci = ct.getActiveFormula();
1.296 CalcHead ch = (CalcHead) ci.getFormula();
1.297
1.298 - // too sensible against changes in CalcHead !!!
1.299 - // f = new File("isac/src/java-tests/isac/bridge/data/mini-auto-step",
1.300 - // "step_b.calcHead");
1.301 - // try {
1.302 - // ObjectInputStream ois = new ObjectInputStream(
1.303 - // new FileInputStream(f));
1.304 - // test = (CalcHead) ois.readObject();
1.305 - // ois.close();
1.306 - // } catch (IOException e) {
1.307 - // e.printStackTrace();
1.308 - // } catch (ClassNotFoundException e) {
1.309 - // e.printStackTrace();
1.310 - // }
1.311 - // System.out.println(".calchead: " + ch.toSMLString());
1.312 - // assertEquals("mini-step: calcHead", ch.toSMLString(), ((CalcHead) test)
1.313 - // .toSMLString());
1.314 System.out.println(".end step_b-----");
1.315 //end step_b
1.316 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.317 @@ -283,13 +267,13 @@
1.318 cce.getLastGeneratedFormula(), new Integer(2), false);
1.319 // before getElementsFromTo:
1.320 // CalcFormula fa = (CalcFormula)
1.321 - (cce.getLastGeneratedFormula()).getFormula();
1.322 + (cce.getLastGeneratedFormula()).getFormula();
1.323 // TODO introduce getElementsFromTo below in setNextTactic
1.324 CalcFormula fa = (CalcFormula) (elems.firstElement());
1.325 System.out.println(".2nd form: " + fa.toSMLString());
1.326 assertEquals("mini-auto: 2nd form", fa.toSMLString(), "x + 1 = 2");
1.327
1.328 - System.out.println(".end step_d-----");
1.329 + System.out.println(".end step_c-----");
1.330 //end step_c
1.331 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.332
1.333 @@ -320,366 +304,373 @@
1.334 assertEquals("mini-auto: 3rd form", fa.toSMLString(),
1.335 "x + 1 + -1 * 2 = 0");
1.336
1.337 - System.out.println(".end step_e-----");
1.338 + System.out.println(".end step_d-----");
1.339 //end step_d
1.340 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.341
1.342 - //let calculate the third formula
1.343 - tac = ct.fetchProposedTactic();
1.344 - assertEquals("mini-step: 4th tac", tac.toSMLString(),
1.345 - "Rewrite_Set \"Test_simplify\"");
1.346 -
1.347 + //set next a NOT applicable tactis (the one from above)
1.348 ct.setNextTactic(tac);
1.349 cce = ((MockIToUser) user).getCalcChangedEvent();
1.350 - //@@@@@error@@@error@@@error@@@error@@@error@@@----"([2],Res)"
1.351 - assertEquals("unchanged", cce.getLastUnchangedFormula().toSMLString(),
1.352 - "([2],Res)");//"([1],Res)");...correct, but see
1.353 - // CalcTree#setNextTactic
1.354 - //@@@@@error@@@error@@@error@@@error@@@error@@@----"([2],Res)"
1.355 - assertEquals("deleted", cce.getLastDeletedFormula().toSMLString(),
1.356 - "([2],Res)");//"([1],Res)");...correct, but see
1.357 - // CalcTree#setNextTactic
1.358 - assertEquals("generated", cce.getLastGeneratedFormula().toSMLString(),
1.359 - "([2],Res)");
1.360 -
1.361 - fa = (CalcFormula) (cce.getLastGeneratedFormula()).getFormula();
1.362 - System.out.println(".4th form:" + fa.toSMLString());
1.363 - assertEquals("mini-auto: 4th form", fa.toSMLString(), "-1 + x = 0");
1.364 -
1.365 - System.out.println(".end step_f-----");
1.366 + //.....WN050222 implicit autoCalculate disturbs the following step
1.367 + System.out.println(".end step_e-----");
1.368 //end step_e
1.369 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.370 +
1.371 +// //let calculate the third formula
1.372 +// tac = ct.fetchProposedTactic();
1.373 +// assertEquals("mini-step: 4th tac", tac.toSMLString(),
1.374 +// "Rewrite_Set \"Test_simplify\"");
1.375 +//
1.376 +// ct.setNextTactic(tac);
1.377 +// cce = ((MockIToUser) user).getCalcChangedEvent();
1.378 +// //@@@@@error@@@error@@@error@@@error@@@error@@@----"([2],Res)"
1.379 +// assertEquals("unchanged", cce.getLastUnchangedFormula().toSMLString(),
1.380 +// "([2],Res)");//"([1],Res)");...correct, but see
1.381 +// // CalcTree#setNextTactic
1.382 +// //@@@@@error@@@error@@@error@@@error@@@error@@@----"([2],Res)"
1.383 +// assertEquals("deleted", cce.getLastDeletedFormula().toSMLString(),
1.384 +// "([2],Res)");//"([1],Res)");...correct, but see
1.385 +// // CalcTree#setNextTactic
1.386 +// assertEquals("generated", cce.getLastGeneratedFormula().toSMLString(),
1.387 +// "([2],Res)");
1.388 +//
1.389 +// fa = (CalcFormula) (cce.getLastGeneratedFormula()).getFormula();
1.390 +// System.out.println(".4th form:" + fa.toSMLString());
1.391 +// assertEquals("mini-auto: 4th form", fa.toSMLString(), "-1 + x = 0");
1.392 +//
1.393 +// System.out.println(".end step_f-----");
1.394 +// //end step_f
1.395 +// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.396 }
1.397
1.398 - /**
1.399 - * uses the example 'IsacCore/Tests/minipbl_with_mini-subpbl'; comprises
1.400 - the
1.401 - * usecase UC\label{SOLVE:INFO:intermediate-steps} see
1.402 - * sml/systest/FE-interface.sml "interSteps: on 'miniscript with
1.403 - mini-subpbl'"
1.404 - */
1.405 - public void testIntermediateSteps() throws Exception {
1.406 - System.out.println("---BEGIN isac.bridge.TestBridgeInput#testIntermediateSteps");
1.407 - // ~~~~~~this should (repeatedly) be done in a separate method~~~~~~~~~
1.408 - //prepare Formalization for start calculation in step_b
1.409 - Formalization fmz = null;
1.410 - File f = new File(
1.411 - "isac/src/java-tests/isac/bridge/data/mini-auto-step",
1.412 - "step_a.fmz");
1.413 - try {
1.414 - ObjectInputStream ois = new ObjectInputStream(
1.415 - new FileInputStream(f));
1.416 - fmz = (Formalization) ois.readObject();
1.417 - ois.close();
1.418 - } catch (IOException e) {
1.419 - e.printStackTrace();
1.420 - } catch (ClassNotFoundException e) {
1.421 - e.printStackTrace();
1.422 - }
1.423 - //start calculation
1.424 - MathEngine.init("localhost");
1.425 - MathEngine me = MathEngine.getMathEngine();
1.426 - IToCalc ct = me.startCalculation(fmz);
1.427 -
1.428 - IToUser user = new MockIToUser();
1.429 - ct.addDataChangeListener(user);
1.430 - CalcChangedEvent cce = null;
1.431 - ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.432 - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.433 -
1.434 - // intermediateSteps(([2],Res)) gives 6 new steps
1.435 - Position pos = new Position();//([2],Res)
1.436 - pos.addInt("2");pos.setKind("Res");
1.437 - ICalcIterator ci = new CalcIterator((CalcTree)ct, pos);
1.438 -
1.439 - ct.intermediateSteps(ci);
1.440 - cce = ((MockIToUser) user).getCalcChangedEvent();
1.441 - Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.442 - cce.getLastGeneratedFormula(), new Integer(3), false);
1.443 - ICalcElement fch = null;
1.444 - for (int i=0; i<elems.size(); i++) {
1.445 - fch = (ICalcElement) elems.elementAt(i);
1.446 - if (fch instanceof CalcFormula)
1.447 - System.out.println(".step "+i+": "+
1.448 - ((CalcFormula)fch).getPosition().toSMLString()
1.449 - + " "+fch.toSMLString());
1.450 - else
1.451 - System.out.println(".step "+i+": "+
1.452 - ((CalcHead)fch).getPosition().toSMLString()
1.453 - + " "+fch.toSMLString());
1.454 - }
1.455 - System.out.println(".-------");
1.456 - assertEquals("mini-auto: steps= ",elems.size(),7);
1.457 - assertEquals("mini-auto: first step",
1.458 - ((ICalcElement) elems.firstElement()).toSMLString(), "x + 1 + -1 * 2 = 0");
1.459 - assertEquals("mini-auto: last step",
1.460 - ((ICalcElement) elems.lastElement()).toSMLString(), "-1 + x = 0");
1.461 -
1.462 - // intermediateSteps(([3,2],Res)) gives 3 new steps
1.463 - pos = new Position();//([3,2],Res)
1.464 - pos.addInt("3");pos.addInt("2");pos.setKind("Res");
1.465 - ci = new CalcIterator((CalcTree)ct, pos);
1.466 -
1.467 - ct.intermediateSteps(ci);
1.468 - cce = ((MockIToUser) user).getCalcChangedEvent();
1.469 - elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.470 - cce.getLastGeneratedFormula(), new Integer(3), false);
1.471 - fch = null;
1.472 - for (int i=0; i<elems.size(); i++) {
1.473 - fch = (ICalcElement) elems.elementAt(i);
1.474 - if (fch instanceof CalcFormula)
1.475 - System.out.println(".step "+i+": "+
1.476 - ((CalcFormula)fch).getPosition().toSMLString()
1.477 - + " "+fch.toSMLString());
1.478 - else
1.479 - System.out.println(".step "+i+": "+
1.480 - ((CalcHead)fch).getPosition().toSMLString()
1.481 - + " "+fch.toSMLString());
1.482 - }
1.483 - System.out.println(".-------");
1.484 - assertEquals("mini-auto: steps= ",elems.size(),3);
1.485 - assertEquals("mini-auto: first step",
1.486 - ((ICalcElement) elems.firstElement()).toSMLString(), "x = 0 + -1 * -1");
1.487 - assertEquals("mini-auto: last step",
1.488 - ((ICalcElement) elems.lastElement()).toSMLString(), "x = 1");
1.489 -
1.490 - // intermediateSteps(([3],Res)) on CalcHead gives NO new steps
1.491 - pos = new Position();//([3],Res)
1.492 - pos.addInt("3");pos.setKind("Res");
1.493 - ci = new CalcIterator((CalcTree)ct, pos);
1.494 -
1.495 - ct.intermediateSteps(ci);
1.496 - cce = ((MockIToUser) user).getCalcChangedEvent();
1.497 - elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.498 - cce.getLastGeneratedFormula(), new Integer(1), false);
1.499 - fch = null;
1.500 - for (int i=0; i<elems.size(); i++) {
1.501 - fch = (ICalcElement) elems.elementAt(i);
1.502 - if (fch instanceof CalcFormula)
1.503 - System.out.println(".step "+i+": "+
1.504 - ((CalcFormula)fch).getPosition().toSMLString()
1.505 - + " "+fch.toSMLString());
1.506 - else
1.507 - System.out.println(".step "+i+": "+
1.508 - ((CalcHead)fch).getPosition().toSMLString()
1.509 - + " "+fch.toSMLString());
1.510 - }
1.511 - System.out.println(".-------");
1.512 - assertEquals("mini-auto: steps= ",elems.size(),3);
1.513 - assertEquals("mini-auto: first step",
1.514 - ((ICalcElement) elems.firstElement()).toSMLString(), "-1 + x = 0");
1.515 - assertEquals("mini-auto: last step",
1.516 - ((ICalcElement) elems.lastElement()).toSMLString(), "x = 1");
1.517 -
1.518 - // intermediateSteps(([],Res)) gives whole calctree (on 1st level)
1.519 - pos = new Position();//([],Res)
1.520 - pos.setKind("Res");
1.521 - ci = new CalcIterator((CalcTree)ct, pos);
1.522 -
1.523 - ct.intermediateSteps(ci);
1.524 - cce = ((MockIToUser) user).getCalcChangedEvent();
1.525 - elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.526 - cce.getLastGeneratedFormula(), new Integer(1), false);
1.527 - fch = null;
1.528 - for (int i=0; i<elems.size(); i++) {
1.529 - fch = (ICalcElement) elems.elementAt(i);
1.530 - if (fch instanceof CalcFormula)
1.531 - System.out.println(".step "+i+": "+
1.532 - ((CalcFormula)fch).getPosition().toSMLString()
1.533 - + " "+fch.toSMLString());
1.534 - else
1.535 - System.out.println(".step "+i+": "+
1.536 - ((CalcHead)fch).getPosition().toSMLString()
1.537 - + " "+fch.toSMLString());
1.538 - }
1.539 - assertEquals("mini-auto: steps= ",elems.size(),6);
1.540 - assertEquals("mini-auto: first step",
1.541 - ((ICalcElement) elems.firstElement()).toSMLString(), "x + 1 = 2");
1.542 - assertEquals("mini-auto: last step",
1.543 - ((ICalcElement) elems.lastElement()).toSMLString(), "[x = 1]");
1.544 - }
1.545 -
1.546 - /**
1.547 - * uses the example 'IsacCore/Tests/minipbl_with_mini-subpbl'; comprises
1.548 - * the UC\label{SOLVE:HIDE:getTactic} and
1.549 - * UC\label{SOLVE:MANUAL:TACTIC:listall}
1.550 - * see sml/systest/FE-interface.sml '- getTactic, fetchApplicableTactics -'
1.551 - */
1.552 - public void testTactics() throws Exception {
1.553 - System.out.println("---BEGIN isac.bridge.TestBridge#testTactics");
1.554 - // ~~~~~~this should (repeatedly) be done in a separate method~~~~~~~~~
1.555 - //prepare Formalization for start calculation in step_b
1.556 - Formalization fmz = null;
1.557 - File f = new File(
1.558 - "isac/src/java-tests/isac/bridge/data/mini-auto-step",
1.559 - "step_a.fmz");
1.560 - try {
1.561 - ObjectInputStream ois = new ObjectInputStream(
1.562 - new FileInputStream(f));
1.563 - fmz = (Formalization) ois.readObject();
1.564 - ois.close();
1.565 - } catch (IOException e) {
1.566 - e.printStackTrace();
1.567 - } catch (ClassNotFoundException e) {
1.568 - e.printStackTrace();
1.569 - }
1.570 - //start calculation
1.571 - MathEngine.init("localhost");
1.572 - MathEngine me = MathEngine.getMathEngine();
1.573 - IToCalc ct = me.startCalculation(fmz);
1.574 -
1.575 - IToUser user = new MockIToUser();
1.576 - ct.addDataChangeListener(user);
1.577 - CalcChangedEvent cce = null;
1.578 - ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.579 - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.580 -
1.581 - // on (root) CalcHead: also with getApplicableTactics only one Tactic
1.582 - Position pos = new Position();//([],Pbl)
1.583 - pos.setKind("Pbl");
1.584 - ICalcIterator ci = new CalcIterator((CalcTree) ct, pos);
1.585 -
1.586 - Tactic tac = ci.getTactic();// <--------------------------------
1.587 - assertEquals("at ([],Pbl) found: ", ((Tactic) tac).toSMLString(),
1.588 - "Apply_Method [\"Test\",\"squ-equ-test-subpbl1\"]");
1.589 -
1.590 - Vector tacs = ci.getApplicableTactics(99999);// <---------------
1.591 - assertEquals(((Tactic) tacs.firstElement()).toSMLString(),
1.592 - "Apply_Method [\"Test\",\"squ-equ-test-subpbl1\"]");
1.593 - assertEquals("number of appl. tacs = ", tacs.size(), 1);
1.594 -
1.595 - // somewhere in rootproblem: all Tactics in the method
1.596 - pos = new Position();//([1],Res)
1.597 - pos.addInt("1");
1.598 - pos.setKind("Res");
1.599 - ci = new CalcIterator((CalcTree) ct, pos);
1.600 -
1.601 - tac = ci.getTactic();// <---------------------------------------
1.602 - assertEquals(tac.toSMLString(), "Rewrite_Set \"Test_simplify\"");
1.603 -
1.604 - tacs = ci.getApplicableTactics(99999);// <----------------------
1.605 - System.out.println(".at " + ci.toSMLString() + ":");
1.606 - for (int i = 0; i < tacs.size(); i++)
1.607 - System.out.println(".." + ((Tactic) tacs.get(i)).toSMLString());
1.608 - assertEquals("number of appl. tacs = ", tacs.size(), 4);
1.609 -
1.610 - // on CalcHead of subproblem: only Apply_Method
1.611 - pos = new Position();//([3],Pbl)
1.612 - pos.addInt("3");
1.613 - pos.setKind("Pbl");
1.614 - ci = new CalcIterator((CalcTree) ct, pos);
1.615 -
1.616 - tac = ci.getTactic();// <---------------------------------------
1.617 - assertEquals(tac.toSMLString(),
1.618 - "Apply_Method [\"Test\",\"solve_linear\"]");
1.619 -
1.620 - tacs = ci.getApplicableTactics(99999);// <----------------------
1.621 - assertEquals("at ([3],Pbl) found: ", ((Tactic) tacs.firstElement())
1.622 - .toSMLString(), "Apply_Method [\"Test\",\"solve_linear\"]");
1.623 - assertEquals("number of appl. tacs = ", tacs.size(), 1);
1.624 -
1.625 - // somewhere in subproblem: all Tactics in this (other) method
1.626 - pos = new Position();//([3,1],Res)
1.627 - pos.addInt("3");
1.628 - pos.addInt("1");
1.629 - pos.setKind("Res");
1.630 - ci = new CalcIterator((CalcTree) ct, pos);
1.631 -
1.632 - tac = ci.getTactic();// <---------------------------------------
1.633 - assertEquals(tac.toSMLString(),"Rewrite_Set \"Test_simplify\"");
1.634 -
1.635 - tacs = ci.getApplicableTactics(99999);// <----------------------
1.636 - System.out.println(".at " + ci.toSMLString() + ":");
1.637 - for (int i = 0; i < tacs.size(); i++)
1.638 - System.out.println(".." + ((Tactic) tacs.get(i)).toSMLString());
1.639 - assertEquals("at ([3,1],Res) found: ", tacs.size(), 2);
1.640 -
1.641 - // on the result of the subproblem again all tacs of the rootpbl
1.642 - pos = new Position();//([3],Res)
1.643 - pos.addInt("3");
1.644 - pos.setKind("Res");
1.645 - ci = new CalcIterator((CalcTree) ct, pos);
1.646 -
1.647 - tac = ci.getTactic();// <---------------------------------------
1.648 - assertEquals(tac.toSMLString(),"Check_elementwise \"Assumptions\"");
1.649 -
1.650 - tacs = ci.getApplicableTactics(99999);// <----------------------
1.651 - System.out.println(".at " + ci.toSMLString() + ":");
1.652 - for (int i = 0; i < tacs.size(); i++)
1.653 - System.out.println(".." + ((Tactic) tacs.get(i)).toSMLString());
1.654 - assertEquals("at ([3],Res) found: ", tacs.size(), 4);
1.655 -
1.656 - // but on the final result there are _NO_ tacs applicable
1.657 - pos = new Position();//([],Res)
1.658 - pos.setKind("Res");
1.659 - ci = new CalcIterator((CalcTree) ct, pos);
1.660 - // tac = ci.getTactic();// <------------------------------------
1.661 - // tacs = ci.getApplicableTactics(99999);// <-------------------
1.662 - // TODO handle error msg
1.663 - }
1.664 -
1.665 - /**
1.666 - * uses the example 'IsacCore/Tests/rat.equ, asms'; comprises the
1.667 - * usecases UC\label{SOLVE:HELP:assumptions}
1.668 - * and *UC\label{SOLVE:HELP:assumptions-origin}
1.669 - * sml/systest/FE-interface.sml '- getAssumptions, getAccumulatedAsms -'
1.670 - */
1.671 - public void testAssumptions() throws Exception {
1.672 - System.out.println("---BEGIN isac.bridge.TestBridge#testAssumptions");
1.673 -
1.674 - //prepare Formalization for start calculation
1.675 - Formalization fmz = null;
1.676 - KEStoreServices ks = new KEStoreServices(
1.677 - "isac/src/java-tests/isac/kestore/data");
1.678 - Vector vec = ks.loadContent("exp", "exp_IsacCore_Tests_1c.xml");
1.679 - String xmlstr = (String) vec.firstElement();
1.680 - FormalizationDigest fd = new FormalizationDigest();
1.681 - fmz = fd.parseFormalization((String) xmlstr);
1.682 -
1.683 - //start and perform calculation
1.684 - MathEngine.init("localhost");
1.685 - MathEngine me = MathEngine.getMathEngine();
1.686 - IToCalc ct = me.startCalculation(fmz);
1.687 -
1.688 - IToUser user = new MockIToUser();
1.689 - ct.addDataChangeListener(user);
1.690 - CalcChangedEvent cce = null;
1.691 - ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.692 -
1.693 - // for (int i = 0; i < forms.size(); i++)
1.694 - // System.out.println(".asm= "
1.695 - // + ((Formula) forms.elementAt(i)).toSMLString());
1.696 -
1.697 - // here the assumption arises
1.698 - Position pos = new Position();//([3],Res)
1.699 - pos.addInt("3");
1.700 - pos.setKind("Res");
1.701 - CalcIterator ci = new CalcIterator((CalcTree) ct, pos);
1.702 -
1.703 - Assumptions asm = ci.getAssumptions();//<---------------------------
1.704 - Vector forms = asm.getFormulae();
1.705 - assertEquals("asm generated here:", ((Formula) forms.firstElement())
1.706 - .toSMLString(), "9 * x + (x ^^^ 3 + -6 * x ^^^ 2) ~= 0");
1.707 - asm = ci.getAccumulatedAssumptions();//<----------------------------
1.708 - forms = asm.getFormulae();
1.709 - assertEquals("is the only asm:", ((Formula) forms.firstElement())
1.710 - .toSMLString(), "9 * x + (x ^^^ 3 + -6 * x ^^^ 2) ~= 0");
1.711 -
1.712 - // here the assumption is checked
1.713 - pos = new Position();//([5],Res)
1.714 - pos.addInt("5");
1.715 - pos.setKind("Res");
1.716 - ci = new CalcIterator((CalcTree) ct, pos);
1.717 -
1.718 - asm = ci.getAssumptions();//<---------------------------------------
1.719 - forms = asm.getFormulae();
1.720 - assertEquals("here no asm generated:", forms.size(), 0);
1.721 - asm = ci.getAccumulatedAssumptions();//<----------------------------
1.722 - forms = asm.getFormulae();
1.723 - assertEquals("acumulated from above:", ((Formula) forms.firstElement())
1.724 - .toSMLString(), "9 * x + (x ^^^ 3 + -6 * x ^^^ 2) ~= 0");
1.725 -
1.726 - System.out.println("---END isac.bridge.TestBridge");
1.727 - }
1.728 +// /**
1.729 +// * uses the example 'IsacCore/Tests/minipbl_with_mini-subpbl'; comprises
1.730 +// * the usecase UC\label{SOLVE:INFO:intermediate-steps} see
1.731 +// * sml/systest/FE-interface.sml "interSteps: on 'miniscript with
1.732 +// * mini-subpbl'"
1.733 +// */
1.734 +// public void testIntermediateSteps() throws Exception {
1.735 +// System.out.println("---BEGIN isac.bridge.TestBridgeInput#testIntermediateSteps");
1.736 +// // ~~~~~~this should (repeatedly) be done in a separate method~~~~~~~~~
1.737 +// //prepare Formalization for start calculation in step_b
1.738 +// Formalization fmz = null;
1.739 +// File f = new File(
1.740 +// "isac/src/java-tests/isac/bridge/data/mini-auto-step",
1.741 +// "step_a.fmz");
1.742 +// try {
1.743 +// ObjectInputStream ois = new ObjectInputStream(
1.744 +// new FileInputStream(f));
1.745 +// fmz = (Formalization) ois.readObject();
1.746 +// ois.close();
1.747 +// } catch (IOException e) {
1.748 +// e.printStackTrace();
1.749 +// } catch (ClassNotFoundException e) {
1.750 +// e.printStackTrace();
1.751 +// }
1.752 +// //start calculation
1.753 +// MathEngine.init("localhost");
1.754 +// MathEngine me = MathEngine.getMathEngine();
1.755 +// IToCalc ct = me.startCalculation(fmz);
1.756 +//
1.757 +// IToUser user = new MockIToUser();
1.758 +// ct.addDataChangeListener(user);
1.759 +// CalcChangedEvent cce = null;
1.760 +// ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.761 +// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.762 +//
1.763 +// // intermediateSteps(([2],Res)) gives 6 new steps
1.764 +// Position pos = new Position();//([2],Res)
1.765 +// pos.addInt("2");pos.setKind("Res");
1.766 +// ICalcIterator ci = new CalcIterator((CalcTree)ct, pos);
1.767 +//
1.768 +// ct.intermediateSteps(ci);
1.769 +// cce = ((MockIToUser) user).getCalcChangedEvent();
1.770 +// Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.771 +// cce.getLastGeneratedFormula(), new Integer(3), false);
1.772 +// ICalcElement fch = null;
1.773 +// for (int i=0; i<elems.size(); i++) {
1.774 +// fch = (ICalcElement) elems.elementAt(i);
1.775 +// if (fch instanceof CalcFormula)
1.776 +// System.out.println(".step "+i+": "+
1.777 +// ((CalcFormula)fch).getPosition().toSMLString()
1.778 +// + " "+fch.toSMLString());
1.779 +// else
1.780 +// System.out.println(".step "+i+": "+
1.781 +// ((CalcHead)fch).getPosition().toSMLString()
1.782 +// + " "+fch.toSMLString());
1.783 +// }
1.784 +// System.out.println(".-------");
1.785 +// assertEquals("mini-auto: steps= ",elems.size(),7);
1.786 +// assertEquals("mini-auto: first step",
1.787 +// ((ICalcElement) elems.firstElement()).toSMLString(), "x + 1 + -1 * 2 = 0");
1.788 +// assertEquals("mini-auto: last step",
1.789 +// ((ICalcElement) elems.lastElement()).toSMLString(), "-1 + x = 0");
1.790 +//
1.791 +// // intermediateSteps(([3,2],Res)) gives 3 new steps
1.792 +// pos = new Position();//([3,2],Res)
1.793 +// pos.addInt("3");pos.addInt("2");pos.setKind("Res");
1.794 +// ci = new CalcIterator((CalcTree)ct, pos);
1.795 +//
1.796 +// ct.intermediateSteps(ci);
1.797 +// cce = ((MockIToUser) user).getCalcChangedEvent();
1.798 +// elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.799 +// cce.getLastGeneratedFormula(), new Integer(3), false);
1.800 +// fch = null;
1.801 +// for (int i=0; i<elems.size(); i++) {
1.802 +// fch = (ICalcElement) elems.elementAt(i);
1.803 +// if (fch instanceof CalcFormula)
1.804 +// System.out.println(".step "+i+": "+
1.805 +// ((CalcFormula)fch).getPosition().toSMLString()
1.806 +// + " "+fch.toSMLString());
1.807 +// else
1.808 +// System.out.println(".step "+i+": "+
1.809 +// ((CalcHead)fch).getPosition().toSMLString()
1.810 +// + " "+fch.toSMLString());
1.811 +// }
1.812 +// System.out.println(".-------");
1.813 +// assertEquals("mini-auto: steps= ",elems.size(),3);
1.814 +// assertEquals("mini-auto: first step",
1.815 +// ((ICalcElement) elems.firstElement()).toSMLString(), "x = 0 + -1 * -1");
1.816 +// assertEquals("mini-auto: last step",
1.817 +// ((ICalcElement) elems.lastElement()).toSMLString(), "x = 1");
1.818 +//
1.819 +// // intermediateSteps(([3],Res)) on CalcHead gives NO new steps
1.820 +// pos = new Position();//([3],Res)
1.821 +// pos.addInt("3");pos.setKind("Res");
1.822 +// ci = new CalcIterator((CalcTree)ct, pos);
1.823 +//
1.824 +// ct.intermediateSteps(ci);
1.825 +// cce = ((MockIToUser) user).getCalcChangedEvent();
1.826 +// elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.827 +// cce.getLastGeneratedFormula(), new Integer(1), false);
1.828 +// fch = null;
1.829 +// for (int i=0; i<elems.size(); i++) {
1.830 +// fch = (ICalcElement) elems.elementAt(i);
1.831 +// if (fch instanceof CalcFormula)
1.832 +// System.out.println(".step "+i+": "+
1.833 +// ((CalcFormula)fch).getPosition().toSMLString()
1.834 +// + " "+fch.toSMLString());
1.835 +// else
1.836 +// System.out.println(".step "+i+": "+
1.837 +// ((CalcHead)fch).getPosition().toSMLString()
1.838 +// + " "+fch.toSMLString());
1.839 +// }
1.840 +// System.out.println(".-------");
1.841 +// assertEquals("mini-auto: steps= ",elems.size(),3);
1.842 +// assertEquals("mini-auto: first step",
1.843 +// ((ICalcElement) elems.firstElement()).toSMLString(), "-1 + x = 0");
1.844 +// assertEquals("mini-auto: last step",
1.845 +// ((ICalcElement) elems.lastElement()).toSMLString(), "x = 1");
1.846 +//
1.847 +// // intermediateSteps(([],Res)) gives whole calctree (on 1st level)
1.848 +// pos = new Position();//([],Res)
1.849 +// pos.setKind("Res");
1.850 +// ci = new CalcIterator((CalcTree)ct, pos);
1.851 +//
1.852 +// ct.intermediateSteps(ci);
1.853 +// cce = ((MockIToUser) user).getCalcChangedEvent();
1.854 +// elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.855 +// cce.getLastGeneratedFormula(), new Integer(1), false);
1.856 +// fch = null;
1.857 +// for (int i=0; i<elems.size(); i++) {
1.858 +// fch = (ICalcElement) elems.elementAt(i);
1.859 +// if (fch instanceof CalcFormula)
1.860 +// System.out.println(".step "+i+": "+
1.861 +// ((CalcFormula)fch).getPosition().toSMLString()
1.862 +// + " "+fch.toSMLString());
1.863 +// else
1.864 +// System.out.println(".step "+i+": "+
1.865 +// ((CalcHead)fch).getPosition().toSMLString()
1.866 +// + " "+fch.toSMLString());
1.867 +// }
1.868 +// assertEquals("mini-auto: steps= ",elems.size(),6);
1.869 +// assertEquals("mini-auto: first step",
1.870 +// ((ICalcElement) elems.firstElement()).toSMLString(), "x + 1 = 2");
1.871 +// assertEquals("mini-auto: last step",
1.872 +// ((ICalcElement) elems.lastElement()).toSMLString(), "[x = 1]");
1.873 +// }
1.874 +//
1.875 +// /**
1.876 +// * uses the example 'IsacCore/Tests/minipbl_with_mini-subpbl'; comprises
1.877 +// * the UC\label{SOLVE:HIDE:getTactic} and
1.878 +// * UC\label{SOLVE:MANUAL:TACTIC:listall}
1.879 +// * see sml/systest/FE-interface.sml '- getTactic, fetchApplicableTactics -'
1.880 +// */
1.881 +// public void testTactics() throws Exception {
1.882 +// System.out.println("---BEGIN isac.bridge.TestBridge#testTactics");
1.883 +// // ~~~~~~this should (repeatedly) be done in a separate method~~~~~~~~~
1.884 +// //prepare Formalization for start calculation in step_b
1.885 +// Formalization fmz = null;
1.886 +// File f = new File(
1.887 +// "isac/src/java-tests/isac/bridge/data/mini-auto-step",
1.888 +// "step_a.fmz");
1.889 +// try {
1.890 +// ObjectInputStream ois = new ObjectInputStream(
1.891 +// new FileInputStream(f));
1.892 +// fmz = (Formalization) ois.readObject();
1.893 +// ois.close();
1.894 +// } catch (IOException e) {
1.895 +// e.printStackTrace();
1.896 +// } catch (ClassNotFoundException e) {
1.897 +// e.printStackTrace();
1.898 +// }
1.899 +// //start calculation
1.900 +// MathEngine.init("localhost");
1.901 +// MathEngine me = MathEngine.getMathEngine();
1.902 +// IToCalc ct = me.startCalculation(fmz);
1.903 +//
1.904 +// IToUser user = new MockIToUser();
1.905 +// ct.addDataChangeListener(user);
1.906 +// CalcChangedEvent cce = null;
1.907 +// ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.908 +// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.909 +//
1.910 +// // on (root) CalcHead: also with getApplicableTactics only one Tactic
1.911 +// Position pos = new Position();//([],Pbl)
1.912 +// pos.setKind("Pbl");
1.913 +// ICalcIterator ci = new CalcIterator((CalcTree) ct, pos);
1.914 +//
1.915 +// Tactic tac = ci.getTactic();// <--------------------------------
1.916 +// assertEquals("at ([],Pbl) found: ", ((Tactic) tac).toSMLString(),
1.917 +// "Apply_Method [\"Test\",\"squ-equ-test-subpbl1\"]");
1.918 +//
1.919 +// Vector tacs = ci.getApplicableTactics(99999);// <---------------
1.920 +// assertEquals(((Tactic) tacs.firstElement()).toSMLString(),
1.921 +// "Apply_Method [\"Test\",\"squ-equ-test-subpbl1\"]");
1.922 +// assertEquals("number of appl. tacs = ", tacs.size(), 1);
1.923 +//
1.924 +// // somewhere in rootproblem: all Tactics in the method
1.925 +// pos = new Position();//([1],Res)
1.926 +// pos.addInt("1");
1.927 +// pos.setKind("Res");
1.928 +// ci = new CalcIterator((CalcTree) ct, pos);
1.929 +//
1.930 +// tac = ci.getTactic();// <---------------------------------------
1.931 +// assertEquals(tac.toSMLString(), "Rewrite_Set \"Test_simplify\"");
1.932 +//
1.933 +// tacs = ci.getApplicableTactics(99999);// <----------------------
1.934 +// System.out.println(".at " + ci.toSMLString() + ":");
1.935 +// for (int i = 0; i < tacs.size(); i++)
1.936 +// System.out.println(".." + ((Tactic) tacs.get(i)).toSMLString());
1.937 +// assertEquals("number of appl. tacs = ", tacs.size(), 4);
1.938 +//
1.939 +// // on CalcHead of subproblem: only Apply_Method
1.940 +// pos = new Position();//([3],Pbl)
1.941 +// pos.addInt("3");
1.942 +// pos.setKind("Pbl");
1.943 +// ci = new CalcIterator((CalcTree) ct, pos);
1.944 +//
1.945 +// tac = ci.getTactic();// <---------------------------------------
1.946 +// assertEquals(tac.toSMLString(),
1.947 +// "Apply_Method [\"Test\",\"solve_linear\"]");
1.948 +//
1.949 +// tacs = ci.getApplicableTactics(99999);// <----------------------
1.950 +// assertEquals("at ([3],Pbl) found: ", ((Tactic) tacs.firstElement())
1.951 +// .toSMLString(), "Apply_Method [\"Test\",\"solve_linear\"]");
1.952 +// assertEquals("number of appl. tacs = ", tacs.size(), 1);
1.953 +//
1.954 +// // somewhere in subproblem: all Tactics in this (other) method
1.955 +// pos = new Position();//([3,1],Res)
1.956 +// pos.addInt("3");
1.957 +// pos.addInt("1");
1.958 +// pos.setKind("Res");
1.959 +// ci = new CalcIterator((CalcTree) ct, pos);
1.960 +//
1.961 +// tac = ci.getTactic();// <---------------------------------------
1.962 +// assertEquals(tac.toSMLString(),"Rewrite_Set \"Test_simplify\"");
1.963 +//
1.964 +// tacs = ci.getApplicableTactics(99999);// <----------------------
1.965 +// System.out.println(".at " + ci.toSMLString() + ":");
1.966 +// for (int i = 0; i < tacs.size(); i++)
1.967 +// System.out.println(".." + ((Tactic) tacs.get(i)).toSMLString());
1.968 +// assertEquals("at ([3,1],Res) found: ", tacs.size(), 2);
1.969 +//
1.970 +// // on the result of the subproblem again all tacs of the rootpbl
1.971 +// pos = new Position();//([3],Res)
1.972 +// pos.addInt("3");
1.973 +// pos.setKind("Res");
1.974 +// ci = new CalcIterator((CalcTree) ct, pos);
1.975 +//
1.976 +// tac = ci.getTactic();// <---------------------------------------
1.977 +// assertEquals(tac.toSMLString(),"Check_elementwise \"Assumptions\"");
1.978 +//
1.979 +// tacs = ci.getApplicableTactics(99999);// <----------------------
1.980 +// System.out.println(".at " + ci.toSMLString() + ":");
1.981 +// for (int i = 0; i < tacs.size(); i++)
1.982 +// System.out.println(".." + ((Tactic) tacs.get(i)).toSMLString());
1.983 +// assertEquals("at ([3],Res) found: ", tacs.size(), 4);
1.984 +//
1.985 +// // but on the final result there are _NO_ tacs applicable
1.986 +// pos = new Position();//([],Res)
1.987 +// pos.setKind("Res");
1.988 +// ci = new CalcIterator((CalcTree) ct, pos);
1.989 +// // tac = ci.getTactic();// <------------------------------------
1.990 +// // tacs = ci.getApplicableTactics(99999);// <-------------------
1.991 +// // TODO handle error msg
1.992 +// }
1.993 +//
1.994 +// /**
1.995 +// * uses the example 'IsacCore/Tests/rat.equ, asms'; comprises the
1.996 +// * usecases UC\label{SOLVE:HELP:assumptions}
1.997 +// * and *UC\label{SOLVE:HELP:assumptions-origin}
1.998 +// * sml/systest/FE-interface.sml '- getAssumptions, getAccumulatedAsms -'
1.999 +// */
1.1000 +// public void testAssumptions() throws Exception {
1.1001 +// System.out.println("---BEGIN isac.bridge.TestBridge#testAssumptions");
1.1002 +//
1.1003 +// //prepare Formalization for start calculation
1.1004 +// Formalization fmz = null;
1.1005 +// KEStoreServices ks = new KEStoreServices(
1.1006 +// "isac/src/java-tests/isac/kestore/data");
1.1007 +// Vector vec = ks.loadContent("exp", "exp_IsacCore_Tests_1c.xml");
1.1008 +// String xmlstr = (String) vec.firstElement();
1.1009 +// FormalizationDigest fd = new FormalizationDigest();
1.1010 +// fmz = fd.parseFormalization((String) xmlstr);
1.1011 +//
1.1012 +// //start and perform calculation
1.1013 +// MathEngine.init("localhost");
1.1014 +// MathEngine me = MathEngine.getMathEngine();
1.1015 +// IToCalc ct = me.startCalculation(fmz);
1.1016 +//
1.1017 +// IToUser user = new MockIToUser();
1.1018 +// ct.addDataChangeListener(user);
1.1019 +// CalcChangedEvent cce = null;
1.1020 +// ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.1021 +//
1.1022 +// // for (int i = 0; i < forms.size(); i++)
1.1023 +// // System.out.println(".asm= "
1.1024 +// // + ((Formula) forms.elementAt(i)).toSMLString());
1.1025 +//
1.1026 +// // here the assumption arises
1.1027 +// Position pos = new Position();//([3],Res)
1.1028 +// pos.addInt("3");
1.1029 +// pos.setKind("Res");
1.1030 +// CalcIterator ci = new CalcIterator((CalcTree) ct, pos);
1.1031 +//
1.1032 +// Assumptions asm = ci.getAssumptions();//<---------------------------
1.1033 +// Vector forms = asm.getFormulae();
1.1034 +// assertEquals("asm generated here:", ((Formula) forms.firstElement())
1.1035 +// .toSMLString(), "9 * x + (x ^^^ 3 + -6 * x ^^^ 2) ~= 0");
1.1036 +// asm = ci.getAccumulatedAssumptions();//<----------------------------
1.1037 +// forms = asm.getFormulae();
1.1038 +// assertEquals("is the only asm:", ((Formula) forms.firstElement())
1.1039 +// .toSMLString(), "9 * x + (x ^^^ 3 + -6 * x ^^^ 2) ~= 0");
1.1040 +//
1.1041 +// // here the assumption is checked
1.1042 +// pos = new Position();//([5],Res)
1.1043 +// pos.addInt("5");
1.1044 +// pos.setKind("Res");
1.1045 +// ci = new CalcIterator((CalcTree) ct, pos);
1.1046 +//
1.1047 +// asm = ci.getAssumptions();//<---------------------------------------
1.1048 +// forms = asm.getFormulae();
1.1049 +// assertEquals("here no asm generated:", forms.size(), 0);
1.1050 +// asm = ci.getAccumulatedAssumptions();//<----------------------------
1.1051 +// forms = asm.getFormulae();
1.1052 +// assertEquals("acumulated from above:", ((Formula) forms.firstElement())
1.1053 +// .toSMLString(), "9 * x + (x ^^^ 3 + -6 * x ^^^ 2) ~= 0");
1.1054 +//
1.1055 +// System.out.println("---END isac.bridge.TestBridge");
1.1056 +// }
1.1057
1.1058 }
1.1059 \ No newline at end of file
2.1 --- a/src/java-tests/isac/util/parser/TestXMLParserDigest.java Fri Mar 11 04:48:03 2005 +0100
2.2 +++ b/src/java-tests/isac/util/parser/TestXMLParserDigest.java Fri Mar 11 10:46:31 2005 +0100
2.3 @@ -4,6 +4,8 @@
2.4 * created Nov 4, 2004, 2:31:27 PM
2.5 * Institute for Softwaretechnology, Graz University of Technology, Austria.
2.6 *
2.7 + * MAKE saxParseError VISIBLE BY .....?????
2.8 + *
2.9 * Use is subject to license terms.
2.10 */
2.11 package isac.util.parser;
2.12 @@ -50,6 +52,7 @@
2.13 logger_
2.14 .debug("---testParseRefFormula begin@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
2.15 xml_parser_digest_ = new XMLParserDigest("isac/src/xml/isac.dtd");
2.16 + xml_parser_digest_.setValidating(true);
2.17 String xmlString = "> @@@@@begin@@@@@" //...........................
2.18 + " 1 " //.........................................
2.19 + "<REFFORMULA>" //...............................
2.20 @@ -81,6 +84,7 @@
2.21 logger_
2.22 .debug("---testParseRefFormula begin%%%%%%%%%%%%%%%%%%%%%%%%%%%");
2.23 xml_parser_digest_ = new XMLParserDigest("isac/src/xml/isac.dtd");
2.24 + xml_parser_digest_.setValidating(true);
2.25 String xmlString = "> @@@@@begin@@@@@" //...........................
2.26 + " 1" //..........................................
2.27 + "<REFFORMULA>" //...............................
2.28 @@ -140,6 +144,7 @@
2.29 logger_
2.30 .debug("---testParseCalcChanged begin############################");
2.31 xml_parser_digest_ = new XMLParserDigest("isac/src/xml/isac.dtd");
2.32 + xml_parser_digest_.setValidating(true);
2.33 String xmlString = "> @@@@@begin@@@@@" //...........................
2.34 + " 1 " //.........................................
2.35 + "<AUTOCALC>" //..................................
2.36 @@ -167,6 +172,7 @@
2.37 + "@@@@@end@@@@@";
2.38 System.out.println("---testParseCalcChanged before parsing");
2.39 wrapper_ = xml_parser_digest_.parse(xmlString);
2.40 + xml_parser_digest_.setValidating(true);
2.41 System.out.println("---testParseCalcChanged after parsing");
2.42
2.43 CalcChanged cc = (CalcChanged) wrapper_.getResponse();
2.44 @@ -186,6 +192,7 @@
2.45 logger_
2.46 .debug("---testParseCalcIterator begin###########################");
2.47 xml_parser_digest_ = new XMLParserDigest("isac/src/xml/isac.dtd");
2.48 + xml_parser_digest_.setValidating(true);
2.49 String xmlString = "> @@@@@begin@@@@@" //...........................
2.50 + " 1 " //......................................................
2.51 + "<CALCITERATOR>" //...........................................
2.52 @@ -210,6 +217,7 @@
2.53 logger_
2.54 .debug("---testParseIteratorError begin##########################");
2.55 xml_parser_digest_ = new XMLParserDigest("isac/src/xml/isac.dtd");
2.56 + xml_parser_digest_.setValidating(true);
2.57 String xmlString = "> @@@@@begin@@@@@" //...........................
2.58 + " 1 " //......................................................
2.59 + "<CALCITERATOR>" //...........................................
2.60 @@ -218,7 +226,6 @@
2.61 + "</CALCITERATOR>" //..........................................
2.62 + "@@@@@end@@@@@";
2.63
2.64 -
2.65 System.out.println("---testParseIteratorError before parsing");
2.66 wrapper_ = xml_parser_digest_.parse(xmlString);
2.67 System.out.println("---testParseIteratorError after parsing");
2.68 @@ -231,6 +238,7 @@
2.69 logger_
2.70 .debug("---testParseIteratorError begin##########################");
2.71 xml_parser_digest_ = new XMLParserDigest("isac/src/xml/isac.dtd");
2.72 + xml_parser_digest_.setValidating(true);
2.73 String xmlString = "> @@@@@begin@@@@@" //...........................
2.74 + " 1 " //......................................................
2.75 + "<GETELEMENTSFROMTO>" //............................................
2.76 @@ -334,6 +342,7 @@
2.77
2.78 System.out.println("---testParseGetElementsFromTo before parsing");
2.79 wrapper_ = xml_parser_digest_.parse(xmlString);
2.80 + xml_parser_digest_.setValidating(true);
2.81 int ci = wrapper_.getCalcID();
2.82 CalcElement fch = (CalcElement) ((FormHeadsContainer) wrapper_
2.83 .getResponse()).getElements().elementAt(2);
2.84 @@ -348,6 +357,7 @@
2.85 logger_
2.86 .debug("---testParseGetTactic begin##########################");
2.87 xml_parser_digest_ = new XMLParserDigest("isac/src/xml/isac.dtd");
2.88 + xml_parser_digest_.setValidating(true);
2.89 String xmlString = "@@@@@begin@@@@@" //...........................................................
2.90 + " 1" //.................................................................
2.91 + " <GETTACTIC>" //.........................................................
2.92 @@ -370,6 +380,7 @@
2.93 logger_
2.94 .debug("---testParseFetchApplicableTactics begin###############");
2.95 xml_parser_digest_ = new XMLParserDigest("isac/src/xml/isac.dtd");
2.96 + xml_parser_digest_.setValidating(true);
2.97 String xmlString = "> @@@@@begin@@@@@" //...........................
2.98 + " 1 " //......................................................
2.99 + "<APPLICABLETACTICS>" //.......................................
2.100 @@ -413,6 +424,7 @@
2.101 logger_
2.102 .debug("---testParseGetAssumptions begin##########################");
2.103 xml_parser_digest_ = new XMLParserDigest("isac/src/xml/isac.dtd");
2.104 + xml_parser_digest_.setValidating(true);
2.105 String xmlString = "@@@@@begin@@@@@" //...........................................................
2.106 + " 1" //...........................................................
2.107 + " <GETASSUMPTIONS>" //.......................................................
3.1 --- a/src/java/isac/wsdialog/DialogIterator.java Fri Mar 11 04:48:03 2005 +0100
3.2 +++ b/src/java/isac/wsdialog/DialogIterator.java Fri Mar 11 10:46:31 2005 +0100
3.3 @@ -164,7 +164,7 @@
3.4
3.5 public Object clone(){
3.6 try {
3.7 - return new DialogIterator((CalcIterator) calc_iterator_.clone());
3.8 + return new DialogIterator((CalcIterator) calc_iterator_.clone(), dialog_);
3.9 } catch (Exception e){
3.10 e.printStackTrace();
3.11 }