22 #include "utilities.hpp"
32 #include "sbml/math/ASTNode.h"
33 #include "sbml/SBMLDocument.h"
34 #include "sbml/Model.h"
35 #include "sbml/Compartment.h"
36 #include "sbml/Species.h"
37 #include "sbml/Parameter.h"
38 #include "sbml/Rule.h"
39 #include "sbml/UnitDefinition.h"
40 #include "sbml/Unit.h"
41 #include "sbml/UnitKind.h"
42 #include "sbml/Event.h"
43 #include "sbml/Trigger.h"
44 #include "sbml/Delay.h"
45 #include "sbml/EventAssignment.h"
69 CPPUNIT_ASSERT(pModel != NULL);
70 CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() ==
CModel::mMol);
71 CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() ==
CModel::ml);
72 CPPUNIT_ASSERT(pModel->getTimeUnitEnum() ==
CModel::s);
73 CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
74 CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
75 CMetab* pA = pModel->getMetabolites()[0];
76 CPPUNIT_ASSERT(pA != NULL);
77 CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
78 const CModelValue* pModelValue = pModel->getModelValues()[0];
79 CPPUNIT_ASSERT(pModelValue != NULL);
80 CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
81 const CEvent* pEvent = pModel->getEvents()[0];
82 CPPUNIT_ASSERT(pEvent != NULL);
84 const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
85 CPPUNIT_ASSERT(pExpr != NULL);
87 CPPUNIT_ASSERT(pNode != NULL);
91 CPPUNIT_ASSERT(pNode != NULL);
94 CPPUNIT_ASSERT(pObjectNode != NULL);
96 CPPUNIT_ASSERT(!objectCN.empty());
97 std::vector<CCopasiContainer*> listOfContainers;
98 listOfContainers.push_back(pModel);
100 CPPUNIT_ASSERT(pObject != NULL);
102 CPPUNIT_ASSERT(pObject->
getObjectName() == std::string(
"Time"));
105 CPPUNIT_ASSERT(pNode != NULL);
108 CPPUNIT_ASSERT(pNumberNode != NULL);
109 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 2.0) / 2.0) < 1e-6);
111 pExpr = pEvent->getDelayExpressionPtr();
112 CPPUNIT_ASSERT(pExpr != NULL);
113 pNode = pExpr->getRoot();
114 CPPUNIT_ASSERT(pNode != NULL);
117 CPPUNIT_ASSERT(pNumberNode != NULL);
118 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 10.0) / 10.0) < 1e-6);
120 CPPUNIT_ASSERT(pEvent->getDelayAssignment() ==
true);
122 CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
124 std::string key = pEvent->getAssignments()[0]->getTargetKey();
125 CPPUNIT_ASSERT(key == pA->getKey());
126 pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
127 CPPUNIT_ASSERT(pExpr != NULL);
128 pNode = pExpr->getRoot();
129 CPPUNIT_ASSERT(pNode != NULL);
132 CPPUNIT_ASSERT(pObjectNode != NULL);
134 CPPUNIT_ASSERT(!objectCN.empty());
136 CPPUNIT_ASSERT(pObject != NULL);
137 CPPUNIT_ASSERT(pObject->isReference() ==
true);
138 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"Value"));
139 CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
143 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
144 "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">"
145 " <model id=\"Model_1\" name=\"New Model\">"
147 " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
148 " <p>L2V1 model with event and delay expression.</p>"
151 " <listOfUnitDefinitions>"
152 " <unitDefinition id=\"volume\">"
154 " <unit kind=\"litre\" scale=\"-3\"/>"
157 " <unitDefinition id=\"substance\">"
159 " <unit kind=\"mole\" scale=\"-3\"/>"
162 " </listOfUnitDefinitions>"
163 " <listOfCompartments>"
164 " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
165 " </listOfCompartments>"
167 " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" />"
169 " <listOfParameters>"
170 " <parameter id=\"parameter_1\" name=\"K\" value=\"0\" constant=\"false\"/>"
171 " </listOfParameters>"
175 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
178 " <csymbol encoding=\"text\" definitionURL=\"http://www.sbml.org/sbml/symbols/time\"> time </csymbol>"
184 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
188 " <listOfEventAssignments>"
189 " <eventAssignment variable=\"species_1\">"
190 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
191 " <ci> parameter_1 </ci>"
193 " </eventAssignment>"
194 " </listOfEventAssignments>"
206 CPPUNIT_ASSERT(pModel != NULL);
207 CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() ==
CModel::mMol);
208 CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() ==
CModel::ml);
209 CPPUNIT_ASSERT(pModel->getTimeUnitEnum() ==
CModel::s);
210 CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
211 CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
212 CMetab* pA = pModel->getMetabolites()[0];
213 CPPUNIT_ASSERT(pA != NULL);
214 CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
215 const CModelValue* pModelValue = pModel->getModelValues()[0];
216 CPPUNIT_ASSERT(pModelValue != NULL);
217 CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
218 const CEvent* pEvent = pModel->getEvents()[0];
219 CPPUNIT_ASSERT(pEvent != NULL);
221 const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
222 CPPUNIT_ASSERT(pExpr != NULL);
224 CPPUNIT_ASSERT(pNode != NULL);
228 CPPUNIT_ASSERT(pNode != NULL);
231 CPPUNIT_ASSERT(pObjectNode != NULL);
233 CPPUNIT_ASSERT(!objectCN.empty());
234 std::vector<CCopasiContainer*> listOfContainers;
235 listOfContainers.push_back(pModel);
237 CPPUNIT_ASSERT(pObject != NULL);
239 CPPUNIT_ASSERT(pObject->
getObjectName() == std::string(
"Time"));
242 CPPUNIT_ASSERT(pNode != NULL);
245 CPPUNIT_ASSERT(pNumberNode != NULL);
246 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 2.0) / 2.0) < 1e-6);
248 pExpr = pEvent->getDelayExpressionPtr();
249 CPPUNIT_ASSERT(pExpr == NULL);
251 CPPUNIT_ASSERT(pEvent->getDelayAssignment() ==
true);
253 CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
255 std::string key = pEvent->getAssignments()[0]->getTargetKey();
256 CPPUNIT_ASSERT(key == pA->getKey());
257 pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
258 CPPUNIT_ASSERT(pExpr != NULL);
259 pNode = pExpr->getRoot();
260 CPPUNIT_ASSERT(pNode != NULL);
263 CPPUNIT_ASSERT(pObjectNode != NULL);
265 CPPUNIT_ASSERT(!objectCN.empty());
267 CPPUNIT_ASSERT(pObject != NULL);
268 CPPUNIT_ASSERT(pObject->isReference() ==
true);
269 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"Value"));
270 CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
274 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
275 "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">"
276 " <model id=\"Model_1\" name=\"New Model\">"
278 " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
279 " <p>L2V1 model with event and delay expression.</p>"
282 " <listOfUnitDefinitions>"
283 " <unitDefinition id=\"volume\">"
285 " <unit kind=\"litre\" scale=\"-3\"/>"
288 " <unitDefinition id=\"substance\">"
290 " <unit kind=\"mole\" scale=\"-3\"/>"
293 " </listOfUnitDefinitions>"
294 " <listOfCompartments>"
295 " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
296 " </listOfCompartments>"
298 " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" />"
300 " <listOfParameters>"
301 " <parameter id=\"parameter_1\" name=\"K\" value=\"0\" constant=\"false\"/>"
302 " </listOfParameters>"
306 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
309 " <csymbol encoding=\"text\" definitionURL=\"http://www.sbml.org/sbml/symbols/time\"> time </csymbol>"
314 " <listOfEventAssignments>"
315 " <eventAssignment variable=\"species_1\">"
316 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
317 " <ci> parameter_1 </ci>"
319 " </eventAssignment>"
320 " </listOfEventAssignments>"
332 CPPUNIT_ASSERT(pModel != NULL);
333 CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() ==
CModel::mMol);
334 CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() ==
CModel::ml);
335 CPPUNIT_ASSERT(pModel->getTimeUnitEnum() ==
CModel::s);
336 CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
337 CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
338 CMetab* pA = pModel->getMetabolites()[0];
339 CPPUNIT_ASSERT(pA != NULL);
340 CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
341 const CModelValue* pModelValue = pModel->getModelValues()[0];
342 CPPUNIT_ASSERT(pModelValue != NULL);
343 CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
344 const CEvent* pEvent = pModel->getEvents()[0];
345 CPPUNIT_ASSERT(pEvent != NULL);
347 const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
348 CPPUNIT_ASSERT(pExpr != NULL);
350 CPPUNIT_ASSERT(pNode != NULL);
354 CPPUNIT_ASSERT(pNode != NULL);
357 CPPUNIT_ASSERT(pObjectNode != NULL);
359 CPPUNIT_ASSERT(!objectCN.empty());
360 std::vector<CCopasiContainer*> listOfContainers;
361 listOfContainers.push_back(pModel);
363 CPPUNIT_ASSERT(pObject != NULL);
365 CPPUNIT_ASSERT(pObject->
getObjectName() == std::string(
"Time"));
368 CPPUNIT_ASSERT(pNode != NULL);
371 CPPUNIT_ASSERT(pNumberNode != NULL);
372 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 2.0) / 2.0) < 1e-6);
374 pExpr = pEvent->getDelayExpressionPtr();
375 CPPUNIT_ASSERT(pExpr != NULL);
376 pNode = pExpr->getRoot();
377 CPPUNIT_ASSERT(pNode != NULL);
380 CPPUNIT_ASSERT(pNumberNode != NULL);
381 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 10.0) / 10.0) < 1e-6);
383 CPPUNIT_ASSERT(pEvent->getDelayAssignment() ==
true);
385 CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
387 std::string key = pEvent->getAssignments()[0]->getTargetKey();
388 CPPUNIT_ASSERT(key == pA->getKey());
389 pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
390 CPPUNIT_ASSERT(pExpr != NULL);
391 pNode = pExpr->getRoot();
392 CPPUNIT_ASSERT(pNode != NULL);
395 CPPUNIT_ASSERT(pObjectNode != NULL);
397 CPPUNIT_ASSERT(!objectCN.empty());
399 CPPUNIT_ASSERT(pObject != NULL);
400 CPPUNIT_ASSERT(pObject->isReference() ==
true);
401 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"Value"));
402 CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
406 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
407 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">"
408 " <model id=\"Model_1\" name=\"New Model\">"
410 " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
411 " <p>L2V4 model with event and delay expression.</p>"
414 " <listOfUnitDefinitions>"
415 " <unitDefinition id=\"volume\">"
417 " <unit kind=\"litre\" scale=\"-3\"/>"
420 " <unitDefinition id=\"substance\">"
422 " <unit kind=\"mole\" scale=\"-3\"/>"
425 " </listOfUnitDefinitions>"
426 " <listOfCompartments>"
427 " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
428 " </listOfCompartments>"
430 " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" />"
432 " <listOfParameters>"
433 " <parameter id=\"parameter_1\" name=\"K\" value=\"0\" constant=\"false\"/>"
434 " </listOfParameters>"
438 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
441 " <csymbol encoding=\"text\" definitionURL=\"http://www.sbml.org/sbml/symbols/time\"> time </csymbol>"
447 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
451 " <listOfEventAssignments>"
452 " <eventAssignment variable=\"species_1\">"
453 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
454 " <ci> parameter_1 </ci>"
456 " </eventAssignment>"
457 " </listOfEventAssignments>"
469 CPPUNIT_ASSERT(pModel != NULL);
470 CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() ==
CModel::mMol);
471 CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() ==
CModel::ml);
472 CPPUNIT_ASSERT(pModel->getTimeUnitEnum() ==
CModel::s);
473 CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
474 CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
475 CMetab* pA = pModel->getMetabolites()[0];
476 CPPUNIT_ASSERT(pA != NULL);
477 CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
478 const CModelValue* pModelValue = pModel->getModelValues()[0];
479 CPPUNIT_ASSERT(pModelValue != NULL);
480 CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
481 const CEvent* pEvent = pModel->getEvents()[0];
482 CPPUNIT_ASSERT(pEvent != NULL);
484 const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
485 CPPUNIT_ASSERT(pExpr != NULL);
487 CPPUNIT_ASSERT(pNode != NULL);
491 CPPUNIT_ASSERT(pNode != NULL);
494 CPPUNIT_ASSERT(pObjectNode != NULL);
496 CPPUNIT_ASSERT(!objectCN.empty());
497 std::vector<CCopasiContainer*> listOfContainers;
498 listOfContainers.push_back(pModel);
500 CPPUNIT_ASSERT(pObject != NULL);
502 CPPUNIT_ASSERT(pObject->
getObjectName() == std::string(
"Time"));
505 CPPUNIT_ASSERT(pNode != NULL);
508 CPPUNIT_ASSERT(pNumberNode != NULL);
509 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 2.0) / 2.0) < 1e-6);
511 pExpr = pEvent->getDelayExpressionPtr();
512 CPPUNIT_ASSERT(pExpr != NULL);
513 pNode = pExpr->getRoot();
514 CPPUNIT_ASSERT(pNode != NULL);
517 CPPUNIT_ASSERT(pNumberNode != NULL);
518 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 10.0) / 10.0) < 1e-6);
520 CPPUNIT_ASSERT(pEvent->getDelayAssignment() ==
true);
522 CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
524 std::string key = pEvent->getAssignments()[0]->getTargetKey();
525 CPPUNIT_ASSERT(key == pA->getKey());
526 pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
527 CPPUNIT_ASSERT(pExpr != NULL);
528 pNode = pExpr->getRoot();
529 CPPUNIT_ASSERT(pNode != NULL);
532 CPPUNIT_ASSERT(pObjectNode != NULL);
534 CPPUNIT_ASSERT(!objectCN.empty());
536 CPPUNIT_ASSERT(pObject != NULL);
537 CPPUNIT_ASSERT(pObject->isReference() ==
true);
538 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"Value"));
539 CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
543 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
544 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">"
545 " <model id=\"Model_1\" name=\"New Model\">"
547 " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
548 " <p>L2V4 model with event and delay expression.</p>"
551 " <listOfUnitDefinitions>"
552 " <unitDefinition id=\"volume\">"
554 " <unit kind=\"litre\" scale=\"-3\"/>"
557 " <unitDefinition id=\"substance\">"
559 " <unit kind=\"mole\" scale=\"-3\"/>"
562 " </listOfUnitDefinitions>"
563 " <listOfCompartments>"
564 " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
565 " </listOfCompartments>"
567 " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" />"
569 " <listOfParameters>"
570 " <parameter id=\"parameter_1\" name=\"K\" value=\"0\" constant=\"false\"/>"
571 " </listOfParameters>"
573 " <event useValuesFromTriggerTime=\"true\">"
575 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
578 " <csymbol encoding=\"text\" definitionURL=\"http://www.sbml.org/sbml/symbols/time\"> time </csymbol>"
584 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
588 " <listOfEventAssignments>"
589 " <eventAssignment variable=\"species_1\">"
590 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
591 " <ci> parameter_1 </ci>"
593 " </eventAssignment>"
594 " </listOfEventAssignments>"
606 CPPUNIT_ASSERT(pModel != NULL);
607 CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() ==
CModel::mMol);
608 CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() ==
CModel::ml);
609 CPPUNIT_ASSERT(pModel->getTimeUnitEnum() ==
CModel::s);
610 CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
611 CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
612 CMetab* pA = pModel->getMetabolites()[0];
613 CPPUNIT_ASSERT(pA != NULL);
614 CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
615 const CModelValue* pModelValue = pModel->getModelValues()[0];
616 CPPUNIT_ASSERT(pModelValue != NULL);
617 CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
618 const CEvent* pEvent = pModel->getEvents()[0];
619 CPPUNIT_ASSERT(pEvent != NULL);
621 const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
622 CPPUNIT_ASSERT(pExpr != NULL);
624 CPPUNIT_ASSERT(pNode != NULL);
628 CPPUNIT_ASSERT(pNode != NULL);
631 CPPUNIT_ASSERT(pObjectNode != NULL);
633 CPPUNIT_ASSERT(!objectCN.empty());
634 std::vector<CCopasiContainer*> listOfContainers;
635 listOfContainers.push_back(pModel);
637 CPPUNIT_ASSERT(pObject != NULL);
639 CPPUNIT_ASSERT(pObject->
getObjectName() == std::string(
"Time"));
642 CPPUNIT_ASSERT(pNode != NULL);
645 CPPUNIT_ASSERT(pNumberNode != NULL);
646 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 2.0) / 2.0) < 1e-6);
648 pExpr = pEvent->getDelayExpressionPtr();
649 CPPUNIT_ASSERT(pExpr != NULL);
650 pNode = pExpr->getRoot();
651 CPPUNIT_ASSERT(pNode != NULL);
654 CPPUNIT_ASSERT(pNumberNode != NULL);
655 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 10.0) / 10.0) < 1e-6);
657 CPPUNIT_ASSERT(pEvent->getDelayAssignment() ==
false);
659 CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
661 std::string key = pEvent->getAssignments()[0]->getTargetKey();
662 CPPUNIT_ASSERT(key == pA->getKey());
663 pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
664 CPPUNIT_ASSERT(pExpr != NULL);
665 pNode = pExpr->getRoot();
666 CPPUNIT_ASSERT(pNode != NULL);
669 CPPUNIT_ASSERT(pObjectNode != NULL);
671 CPPUNIT_ASSERT(!objectCN.empty());
673 CPPUNIT_ASSERT(pObject != NULL);
674 CPPUNIT_ASSERT(pObject->isReference() ==
true);
675 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"Value"));
676 CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
680 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
681 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">"
682 " <model id=\"Model_1\" name=\"New Model\">"
684 " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
685 " <p>L2V4 model with event and delay expression.</p>"
688 " <listOfUnitDefinitions>"
689 " <unitDefinition id=\"volume\">"
691 " <unit kind=\"litre\" scale=\"-3\"/>"
694 " <unitDefinition id=\"substance\">"
696 " <unit kind=\"mole\" scale=\"-3\"/>"
699 " </listOfUnitDefinitions>"
700 " <listOfCompartments>"
701 " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
702 " </listOfCompartments>"
704 " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" />"
706 " <listOfParameters>"
707 " <parameter id=\"parameter_1\" name=\"K\" value=\"0\" constant=\"false\"/>"
708 " </listOfParameters>"
710 " <event useValuesFromTriggerTime=\"false\">"
712 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
715 " <csymbol encoding=\"text\" definitionURL=\"http://www.sbml.org/sbml/symbols/time\"> time </csymbol>"
721 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
725 " <listOfEventAssignments>"
726 " <eventAssignment variable=\"species_1\">"
727 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
728 " <ci> parameter_1 </ci>"
730 " </eventAssignment>"
731 " </listOfEventAssignments>"
743 CPPUNIT_ASSERT(pModel != NULL);
744 CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() ==
CModel::mMol);
745 CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() ==
CModel::ml);
746 CPPUNIT_ASSERT(pModel->getTimeUnitEnum() ==
CModel::s);
747 CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
748 CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
749 CMetab* pA = pModel->getMetabolites()[0];
750 CPPUNIT_ASSERT(pA != NULL);
751 CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
752 const CModelValue* pModelValue = pModel->getModelValues()[0];
753 CPPUNIT_ASSERT(pModelValue != NULL);
754 CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
755 const CEvent* pEvent = pModel->getEvents()[0];
756 CPPUNIT_ASSERT(pEvent != NULL);
758 const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
759 CPPUNIT_ASSERT(pExpr != NULL);
761 CPPUNIT_ASSERT(pNode != NULL);
765 CPPUNIT_ASSERT(pNode != NULL);
768 CPPUNIT_ASSERT(pObjectNode != NULL);
770 CPPUNIT_ASSERT(!objectCN.empty());
771 std::vector<CCopasiContainer*> listOfContainers;
772 listOfContainers.push_back(pModel);
774 CPPUNIT_ASSERT(pObject != NULL);
776 CPPUNIT_ASSERT(pObject->
getObjectName() == std::string(
"Time"));
779 CPPUNIT_ASSERT(pNode != NULL);
782 CPPUNIT_ASSERT(pNumberNode != NULL);
783 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 2.0) / 2.0) < 1e-6);
785 pExpr = pEvent->getDelayExpressionPtr();
786 CPPUNIT_ASSERT(pExpr == NULL);
788 CPPUNIT_ASSERT(pEvent->getDelayAssignment() ==
true);
790 CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
792 std::string key = pEvent->getAssignments()[0]->getTargetKey();
793 CPPUNIT_ASSERT(key == pA->getKey());
794 pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
795 CPPUNIT_ASSERT(pExpr != NULL);
796 pNode = pExpr->getRoot();
797 CPPUNIT_ASSERT(pNode != NULL);
800 CPPUNIT_ASSERT(pObjectNode != NULL);
802 CPPUNIT_ASSERT(!objectCN.empty());
804 CPPUNIT_ASSERT(pObject != NULL);
805 CPPUNIT_ASSERT(pObject->isReference() ==
true);
806 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"Value"));
807 CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
811 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
812 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">"
813 " <model id=\"Model_1\" name=\"New Model\">"
815 " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
816 " <p>L2V4 model with event and delay expression.</p>"
819 " <listOfUnitDefinitions>"
820 " <unitDefinition id=\"volume\">"
822 " <unit kind=\"litre\" scale=\"-3\"/>"
825 " <unitDefinition id=\"substance\">"
827 " <unit kind=\"mole\" scale=\"-3\"/>"
830 " </listOfUnitDefinitions>"
831 " <listOfCompartments>"
832 " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
833 " </listOfCompartments>"
835 " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" />"
837 " <listOfParameters>"
838 " <parameter id=\"parameter_1\" name=\"K\" value=\"0\" constant=\"false\"/>"
839 " </listOfParameters>"
843 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
846 " <csymbol encoding=\"text\" definitionURL=\"http://www.sbml.org/sbml/symbols/time\"> time </csymbol>"
851 " <listOfEventAssignments>"
852 " <eventAssignment variable=\"species_1\">"
853 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
854 " <ci> parameter_1 </ci>"
856 " </eventAssignment>"
857 " </listOfEventAssignments>"
869 CPPUNIT_ASSERT(pModel != NULL);
870 CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() ==
CModel::mMol);
871 CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() ==
CModel::ml);
872 CPPUNIT_ASSERT(pModel->getTimeUnitEnum() ==
CModel::s);
873 CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
874 CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
875 CMetab* pA = pModel->getMetabolites()[0];
876 CPPUNIT_ASSERT(pA != NULL);
877 CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
878 const CModelValue* pModelValue = pModel->getModelValues()[0];
879 CPPUNIT_ASSERT(pModelValue != NULL);
880 CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
881 const CEvent* pEvent = pModel->getEvents()[0];
882 CPPUNIT_ASSERT(pEvent != NULL);
884 const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
885 CPPUNIT_ASSERT(pExpr != NULL);
887 CPPUNIT_ASSERT(pNode != NULL);
891 CPPUNIT_ASSERT(pNode != NULL);
894 CPPUNIT_ASSERT(pObjectNode != NULL);
896 CPPUNIT_ASSERT(!objectCN.empty());
897 std::vector<CCopasiContainer*> listOfContainers;
898 listOfContainers.push_back(pModel);
900 CPPUNIT_ASSERT(pObject != NULL);
902 CPPUNIT_ASSERT(pObject->
getObjectName() == std::string(
"Time"));
905 CPPUNIT_ASSERT(pNode != NULL);
908 CPPUNIT_ASSERT(pNumberNode != NULL);
909 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 2.0) / 2.0) < 1e-6);
911 pExpr = pEvent->getDelayExpressionPtr();
912 CPPUNIT_ASSERT(pExpr == NULL);
914 CPPUNIT_ASSERT(pEvent->getDelayAssignment() ==
true);
916 CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
918 std::string key = pEvent->getAssignments()[0]->getTargetKey();
919 CPPUNIT_ASSERT(key == pA->getKey());
920 pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
921 CPPUNIT_ASSERT(pExpr != NULL);
922 pNode = pExpr->getRoot();
923 CPPUNIT_ASSERT(pNode != NULL);
926 CPPUNIT_ASSERT(pObjectNode != NULL);
928 CPPUNIT_ASSERT(!objectCN.empty());
930 CPPUNIT_ASSERT(pObject != NULL);
931 CPPUNIT_ASSERT(pObject->isReference() ==
true);
932 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"Value"));
933 CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
937 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
938 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">"
939 " <model id=\"Model_1\" name=\"New Model\">"
941 " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
942 " <p>L2V4 model with event and delay expression.</p>"
945 " <listOfUnitDefinitions>"
946 " <unitDefinition id=\"volume\">"
948 " <unit kind=\"litre\" scale=\"-3\"/>"
951 " <unitDefinition id=\"substance\">"
953 " <unit kind=\"mole\" scale=\"-3\"/>"
956 " </listOfUnitDefinitions>"
957 " <listOfCompartments>"
958 " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
959 " </listOfCompartments>"
961 " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" />"
963 " <listOfParameters>"
964 " <parameter id=\"parameter_1\" name=\"K\" value=\"0\" constant=\"false\"/>"
965 " </listOfParameters>"
967 " <event useValuesFromTriggerTime=\"true\">"
969 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
972 " <csymbol encoding=\"text\" definitionURL=\"http://www.sbml.org/sbml/symbols/time\"> time </csymbol>"
977 " <listOfEventAssignments>"
978 " <eventAssignment variable=\"species_1\">"
979 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
980 " <ci> parameter_1 </ci>"
982 " </eventAssignment>"
983 " </listOfEventAssignments>"
995 CPPUNIT_ASSERT(pModel != NULL);
996 CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() ==
CModel::mMol);
997 CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() ==
CModel::ml);
998 CPPUNIT_ASSERT(pModel->getTimeUnitEnum() ==
CModel::s);
999 CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1000 CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
1001 CMetab* pA = pModel->getMetabolites()[0];
1002 CPPUNIT_ASSERT(pA != NULL);
1003 CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
1004 const CModelValue* pModelValue = pModel->getModelValues()[0];
1005 CPPUNIT_ASSERT(pModelValue != NULL);
1006 CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
1007 const CEvent* pEvent = pModel->getEvents()[0];
1008 CPPUNIT_ASSERT(pEvent != NULL);
1010 const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
1011 CPPUNIT_ASSERT(pExpr != NULL);
1013 CPPUNIT_ASSERT(pNode != NULL);
1017 CPPUNIT_ASSERT(pNode != NULL);
1020 CPPUNIT_ASSERT(pObjectNode != NULL);
1022 CPPUNIT_ASSERT(!objectCN.empty());
1023 std::vector<CCopasiContainer*> listOfContainers;
1024 listOfContainers.push_back(pModel);
1026 CPPUNIT_ASSERT(pObject != NULL);
1028 CPPUNIT_ASSERT(pObject->
getObjectName() == std::string(
"Time"));
1031 CPPUNIT_ASSERT(pNode != NULL);
1034 CPPUNIT_ASSERT(pNumberNode != NULL);
1035 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 2.0) / 2.0) < 1e-6);
1037 pExpr = pEvent->getDelayExpressionPtr();
1038 CPPUNIT_ASSERT(pExpr == NULL);
1040 CPPUNIT_ASSERT(pEvent->getDelayAssignment() ==
true);
1042 CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
1044 std::string key = pEvent->getAssignments()[0]->getTargetKey();
1045 CPPUNIT_ASSERT(key == pA->getKey());
1046 pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
1047 CPPUNIT_ASSERT(pExpr != NULL);
1048 pNode = pExpr->getRoot();
1049 CPPUNIT_ASSERT(pNode != NULL);
1052 CPPUNIT_ASSERT(pObjectNode != NULL);
1054 CPPUNIT_ASSERT(!objectCN.empty());
1056 CPPUNIT_ASSERT(pObject != NULL);
1057 CPPUNIT_ASSERT(pObject->isReference() ==
true);
1058 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"Value"));
1059 CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
1063 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
1064 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">"
1065 " <model id=\"Model_1\" name=\"New Model\">"
1067 " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
1068 " <p>L2V4 model with event and delay expression.</p>"
1071 " <listOfUnitDefinitions>"
1072 " <unitDefinition id=\"volume\">"
1074 " <unit kind=\"litre\" scale=\"-3\"/>"
1076 " </unitDefinition>"
1077 " <unitDefinition id=\"substance\">"
1079 " <unit kind=\"mole\" scale=\"-3\"/>"
1081 " </unitDefinition>"
1082 " </listOfUnitDefinitions>"
1083 " <listOfCompartments>"
1084 " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
1085 " </listOfCompartments>"
1087 " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" />"
1089 " <listOfParameters>"
1090 " <parameter id=\"parameter_1\" name=\"K\" value=\"0\" constant=\"false\"/>"
1091 " </listOfParameters>"
1093 " <event useValuesFromTriggerTime=\"false\">"
1095 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
1098 " <csymbol encoding=\"text\" definitionURL=\"http://www.sbml.org/sbml/symbols/time\"> time </csymbol>"
1103 " <listOfEventAssignments>"
1104 " <eventAssignment variable=\"species_1\">"
1105 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
1106 " <ci> parameter_1 </ci>"
1108 " </eventAssignment>"
1109 " </listOfEventAssignments>"
1124 CPPUNIT_ASSERT(result ==
true);
1125 CPPUNIT_ASSERT(pDataModel->
getModel() != NULL);
1128 CPPUNIT_ASSERT(pDocument != NULL);
1129 CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1130 CPPUNIT_ASSERT(pDocument->getVersion() == 4);
1131 Model* pModel = pDocument->getModel();
1132 CPPUNIT_ASSERT(pModel != NULL);
1134 UnitDefinition* pUDef = pModel->getUnitDefinition(
"time");
1141 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1142 pUnit = pUDef->getUnit(0);
1143 CPPUNIT_ASSERT(pUnit != NULL);
1144 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1145 CPPUNIT_ASSERT(pUnit->getScale() == 0);
1146 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1147 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1150 pUDef = pModel->getUnitDefinition(
"substance");
1151 CPPUNIT_ASSERT(pUDef != NULL);
1152 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1153 pUnit = pUDef->getUnit(0);
1154 CPPUNIT_ASSERT(pUnit != NULL);
1155 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1156 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1157 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1158 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1159 pUDef = pModel->getUnitDefinition(
"volume");
1160 CPPUNIT_ASSERT(pUDef != NULL);
1161 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1162 pUnit = pUDef->getUnit(0);
1163 CPPUNIT_ASSERT(pUnit != NULL);
1164 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1165 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1166 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1167 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1170 CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1171 CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1172 Parameter* pParameter1 = pModel->getParameter(0);
1173 CPPUNIT_ASSERT(pParameter1 != NULL);
1174 CPPUNIT_ASSERT(pParameter1->getName() ==
"K");
1175 CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1176 Species* pSpecies1 = pModel->getSpecies(0);
1177 CPPUNIT_ASSERT(pSpecies1->getName() ==
"A");
1178 Species* pSpecies2 = pModel->getSpecies(1);
1179 CPPUNIT_ASSERT(pSpecies2->getName() ==
"B");
1180 CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1181 CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1182 CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1183 Event* pEvent = pModel->getEvent(0);
1184 CPPUNIT_ASSERT(pEvent != NULL);
1186 CPPUNIT_ASSERT(pEvent->isSetTrigger());
1187 Trigger* pTrigger = pEvent->getTrigger();
1188 CPPUNIT_ASSERT(pTrigger != NULL);
1189 CPPUNIT_ASSERT(pTrigger->isSetMath());
1190 const ASTNode* pMath = pTrigger->getMath();
1191 CPPUNIT_ASSERT(pMath != NULL);
1192 CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1193 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1194 const ASTNode* pChild = pMath->getChild(0);
1195 CPPUNIT_ASSERT(pChild != NULL);
1196 CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1197 pChild = pMath->getChild(1);
1198 CPPUNIT_ASSERT(pChild != NULL);
1199 CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1200 CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1202 CPPUNIT_ASSERT(pEvent->isSetDelay());
1203 CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() ==
true);
1204 Delay* pDelay = pEvent->getDelay();
1205 CPPUNIT_ASSERT(pDelay != NULL);
1206 CPPUNIT_ASSERT(pDelay->isSetMath());
1207 pMath = pDelay->getMath();
1208 CPPUNIT_ASSERT(pMath != NULL);
1209 CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
1210 CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
1212 CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1213 EventAssignment* pEA = pEvent->getEventAssignment(0);
1214 CPPUNIT_ASSERT(pEA != NULL);
1215 CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1216 pMath = pEA->getMath();
1217 CPPUNIT_ASSERT(pMath != NULL);
1220 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1221 CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1232 CPPUNIT_ASSERT(result ==
true);
1233 CPPUNIT_ASSERT(pDataModel->
getModel() != NULL);
1236 CPPUNIT_ASSERT(pDocument != NULL);
1237 CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1238 CPPUNIT_ASSERT(pDocument->getVersion() == 1);
1239 Model* pModel = pDocument->getModel();
1240 CPPUNIT_ASSERT(pModel != NULL);
1242 UnitDefinition* pUDef = pModel->getUnitDefinition(
"time");
1249 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1250 pUnit = pUDef->getUnit(0);
1251 CPPUNIT_ASSERT(pUnit != NULL);
1252 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1253 CPPUNIT_ASSERT(pUnit->getScale() == 0);
1254 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1255 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1258 pUDef = pModel->getUnitDefinition(
"substance");
1259 CPPUNIT_ASSERT(pUDef != NULL);
1260 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1261 pUnit = pUDef->getUnit(0);
1262 CPPUNIT_ASSERT(pUnit != NULL);
1263 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1264 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1265 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1266 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1267 pUDef = pModel->getUnitDefinition(
"volume");
1268 CPPUNIT_ASSERT(pUDef != NULL);
1269 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1270 pUnit = pUDef->getUnit(0);
1271 CPPUNIT_ASSERT(pUnit != NULL);
1272 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1273 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1274 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1275 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1278 CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1279 CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1280 Parameter* pParameter1 = pModel->getParameter(0);
1281 CPPUNIT_ASSERT(pParameter1 != NULL);
1282 CPPUNIT_ASSERT(pParameter1->getName() ==
"K");
1283 CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1284 Species* pSpecies1 = pModel->getSpecies(0);
1285 CPPUNIT_ASSERT(pSpecies1->getName() ==
"A");
1286 Species* pSpecies2 = pModel->getSpecies(1);
1287 CPPUNIT_ASSERT(pSpecies2->getName() ==
"B");
1288 CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1289 CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1290 CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1291 Event* pEvent = pModel->getEvent(0);
1292 CPPUNIT_ASSERT(pEvent != NULL);
1294 CPPUNIT_ASSERT(pEvent->isSetTrigger());
1295 Trigger* pTrigger = pEvent->getTrigger();
1296 CPPUNIT_ASSERT(pTrigger != NULL);
1297 CPPUNIT_ASSERT(pTrigger->isSetMath());
1298 const ASTNode* pMath = pTrigger->getMath();
1299 CPPUNIT_ASSERT(pMath != NULL);
1300 CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1301 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1302 const ASTNode* pChild = pMath->getChild(0);
1303 CPPUNIT_ASSERT(pChild != NULL);
1304 CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1305 pChild = pMath->getChild(1);
1306 CPPUNIT_ASSERT(pChild != NULL);
1307 CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1308 CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1310 CPPUNIT_ASSERT(pEvent->isSetDelay());
1311 CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() ==
true);
1312 Delay* pDelay = pEvent->getDelay();
1313 CPPUNIT_ASSERT(pDelay != NULL);
1314 CPPUNIT_ASSERT(pDelay->isSetMath());
1315 pMath = pDelay->getMath();
1316 CPPUNIT_ASSERT(pMath != NULL);
1317 CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
1318 CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
1320 CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1321 EventAssignment* pEA = pEvent->getEventAssignment(0);
1322 CPPUNIT_ASSERT(pEA != NULL);
1323 CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1324 pMath = pEA->getMath();
1325 CPPUNIT_ASSERT(pMath != NULL);
1328 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1329 CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1342 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1343 "<!-- generated with COPASI 4.4.26 (Debug) (http://www.copasi.org) at 2008-06-12 09:00:21 UTC -->\n"
1344 "<COPASI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.copasi.org/static/schema.xsd\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"26\">\n"
1345 " <Model key=\"Model_0\" name=\"New Model\" timeUnit=\"s\" volumeUnit=\"ml\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
1347 " <html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:9pt;font-family:Sans Serif\">\n"
1348 "<p>Simple model with two species and one global parameter. The compartment is fixed and one species is changed by an event assignment.</p>\n"
1349 "<p>The substance unit is set to mmol.</p>\n"
1350 "<p>On export both species should be exported with the hasOnlySubstanceUnits flag set to false and the expression for the event assignment should contain a reference to the global parameter.</p>\n"
1353 " <ListOfCompartments>\n"
1354 " <Compartment key=\"Compartment_0\" name=\"compartment\" simulationType=\"fixed\">\n"
1356 " </ListOfCompartments>\n"
1357 " <ListOfMetabolites>\n"
1358 " <Metabolite key=\"Metabolite_0\" name=\"A\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
1360 " <Metabolite key=\"Metabolite_1\" name=\"B\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
1362 " </ListOfMetabolites>\n"
1363 " <ListOfModelValues>\n"
1364 " <ModelValue key=\"ModelValue_0\" name=\"K\" simulationType=\"fixed\">\n"
1366 " </ListOfModelValues>\n"
1368 " <Event key=\"Event_0\" name=\"event\" delayAssignment=\"true\" >\n"
1369 " <TriggerExpression>\n"
1370 " <CN=Root,Model=New Model,Reference=Time> gt 2.0\n"
1371 " </TriggerExpression>\n"
1372 " <DelayExpression>\n"
1374 " </DelayExpression>\n"
1375 " <ListOfAssignments>\n"
1376 " <Assignment targetKey=\"Metabolite_0\">\n"
1378 " <CN=Root,Model=New Model,Vector=Values[K],Reference=Value>\n"
1381 " </ListOfAssignments>\n"
1383 " </ListOfEvents>\n"
1384 " <StateTemplate>\n"
1385 " <StateTemplateVariable objectReference=\"Model_0\"/>\n"
1386 " <StateTemplateVariable objectReference=\"Metabolite_0\"/>\n"
1387 " <StateTemplateVariable objectReference=\"Metabolite_1\"/>\n"
1388 " <StateTemplateVariable objectReference=\"ModelValue_0\"/>\n"
1389 " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
1390 " </StateTemplate>\n"
1391 " <InitialState type=\"initialState\">\n"
1392 " 0 1.2044283e+21 6.022141500000001e+20 2 1\n"
1393 " </InitialState>\n"
1406 CPPUNIT_ASSERT(result ==
true);
1407 CPPUNIT_ASSERT(pDataModel->
getModel() != NULL);
1410 CPPUNIT_ASSERT(pDocument != NULL);
1411 CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1412 CPPUNIT_ASSERT(pDocument->getVersion() == 4);
1413 Model* pModel = pDocument->getModel();
1414 CPPUNIT_ASSERT(pModel != NULL);
1416 UnitDefinition* pUDef = pModel->getUnitDefinition(
"time");
1423 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1424 pUnit = pUDef->getUnit(0);
1425 CPPUNIT_ASSERT(pUnit != NULL);
1426 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1427 CPPUNIT_ASSERT(pUnit->getScale() == 0);
1428 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1429 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1432 pUDef = pModel->getUnitDefinition(
"substance");
1433 CPPUNIT_ASSERT(pUDef != NULL);
1434 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1435 pUnit = pUDef->getUnit(0);
1436 CPPUNIT_ASSERT(pUnit != NULL);
1437 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1438 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1439 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1440 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1441 pUDef = pModel->getUnitDefinition(
"volume");
1442 CPPUNIT_ASSERT(pUDef != NULL);
1443 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1444 pUnit = pUDef->getUnit(0);
1445 CPPUNIT_ASSERT(pUnit != NULL);
1446 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1447 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1448 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1449 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1452 CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1453 CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1454 Parameter* pParameter1 = pModel->getParameter(0);
1455 CPPUNIT_ASSERT(pParameter1 != NULL);
1456 CPPUNIT_ASSERT(pParameter1->getName() ==
"K");
1457 CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1458 Species* pSpecies1 = pModel->getSpecies(0);
1459 CPPUNIT_ASSERT(pSpecies1->getName() ==
"A");
1460 Species* pSpecies2 = pModel->getSpecies(1);
1461 CPPUNIT_ASSERT(pSpecies2->getName() ==
"B");
1462 CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1463 CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1464 CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1465 Event* pEvent = pModel->getEvent(0);
1466 CPPUNIT_ASSERT(pEvent != NULL);
1468 CPPUNIT_ASSERT(pEvent->isSetTrigger());
1469 Trigger* pTrigger = pEvent->getTrigger();
1470 CPPUNIT_ASSERT(pTrigger != NULL);
1471 CPPUNIT_ASSERT(pTrigger->isSetMath());
1472 const ASTNode* pMath = pTrigger->getMath();
1473 CPPUNIT_ASSERT(pMath != NULL);
1474 CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1475 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1476 const ASTNode* pChild = pMath->getChild(0);
1477 CPPUNIT_ASSERT(pChild != NULL);
1478 CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1479 pChild = pMath->getChild(1);
1480 CPPUNIT_ASSERT(pChild != NULL);
1481 CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1482 CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1484 CPPUNIT_ASSERT(pEvent->isSetDelay());
1485 CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() ==
false);
1486 Delay* pDelay = pEvent->getDelay();
1487 CPPUNIT_ASSERT(pDelay != NULL);
1488 CPPUNIT_ASSERT(pDelay->isSetMath());
1489 pMath = pDelay->getMath();
1490 CPPUNIT_ASSERT(pMath != NULL);
1491 CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
1492 CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
1494 CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1495 EventAssignment* pEA = pEvent->getEventAssignment(0);
1496 CPPUNIT_ASSERT(pEA != NULL);
1497 CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1498 pMath = pEA->getMath();
1499 CPPUNIT_ASSERT(pMath != NULL);
1502 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1503 CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1514 CPPUNIT_ASSERT(result ==
true);
1515 CPPUNIT_ASSERT(pDataModel->
getModel() != NULL);
1518 CPPUNIT_ASSERT(pDocument != NULL);
1519 CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1520 CPPUNIT_ASSERT(pDocument->getVersion() == 1);
1521 Model* pModel = pDocument->getModel();
1522 CPPUNIT_ASSERT(pModel != NULL);
1524 UnitDefinition* pUDef = pModel->getUnitDefinition(
"time");
1531 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1532 pUnit = pUDef->getUnit(0);
1533 CPPUNIT_ASSERT(pUnit != NULL);
1534 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1535 CPPUNIT_ASSERT(pUnit->getScale() == 0);
1536 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1537 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1540 pUDef = pModel->getUnitDefinition(
"substance");
1541 CPPUNIT_ASSERT(pUDef != NULL);
1542 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1543 pUnit = pUDef->getUnit(0);
1544 CPPUNIT_ASSERT(pUnit != NULL);
1545 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1546 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1547 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1548 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1549 pUDef = pModel->getUnitDefinition(
"volume");
1550 CPPUNIT_ASSERT(pUDef != NULL);
1551 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1552 pUnit = pUDef->getUnit(0);
1553 CPPUNIT_ASSERT(pUnit != NULL);
1554 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1555 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1556 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1557 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1560 CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1561 CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1562 Parameter* pParameter1 = pModel->getParameter(0);
1563 CPPUNIT_ASSERT(pParameter1 != NULL);
1564 CPPUNIT_ASSERT(pParameter1->getName() ==
"K");
1565 CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1566 Species* pSpecies1 = pModel->getSpecies(0);
1567 CPPUNIT_ASSERT(pSpecies1->getName() ==
"A");
1568 Species* pSpecies2 = pModel->getSpecies(1);
1569 CPPUNIT_ASSERT(pSpecies2->getName() ==
"B");
1570 CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1571 CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1572 CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1573 Event* pEvent = pModel->getEvent(0);
1574 CPPUNIT_ASSERT(pEvent != NULL);
1576 CPPUNIT_ASSERT(pEvent->isSetTrigger());
1577 Trigger* pTrigger = pEvent->getTrigger();
1578 CPPUNIT_ASSERT(pTrigger != NULL);
1579 CPPUNIT_ASSERT(pTrigger->isSetMath());
1580 const ASTNode* pMath = pTrigger->getMath();
1581 CPPUNIT_ASSERT(pMath != NULL);
1582 CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1583 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1584 const ASTNode* pChild = pMath->getChild(0);
1585 CPPUNIT_ASSERT(pChild != NULL);
1586 CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1587 pChild = pMath->getChild(1);
1588 CPPUNIT_ASSERT(pChild != NULL);
1589 CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1590 CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1592 CPPUNIT_ASSERT(pEvent->isSetDelay());
1593 CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() ==
true);
1594 Delay* pDelay = pEvent->getDelay();
1595 CPPUNIT_ASSERT(pDelay != NULL);
1596 CPPUNIT_ASSERT(pDelay->isSetMath());
1597 pMath = pDelay->getMath();
1598 CPPUNIT_ASSERT(pMath != NULL);
1599 CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
1600 CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
1602 CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1603 EventAssignment* pEA = pEvent->getEventAssignment(0);
1604 CPPUNIT_ASSERT(pEA != NULL);
1605 CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1606 pMath = pEA->getMath();
1607 CPPUNIT_ASSERT(pMath != NULL);
1610 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1611 CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1627 CPPUNIT_ASSERT(i != iMax);
1631 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1632 "<!-- generated with COPASI 4.4.26 (Debug) (http://www.copasi.org) at 2008-06-12 09:00:21 UTC -->\n"
1633 "<COPASI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.copasi.org/static/schema.xsd\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"26\">\n"
1634 " <Model key=\"Model_0\" name=\"New Model\" timeUnit=\"s\" volumeUnit=\"ml\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
1636 " <html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:9pt;font-family:Sans Serif\">\n"
1637 "<p>Simple model with two species and one global parameter. The compartment is fixed and one species is changed by an event assignment.</p>\n"
1638 "<p>The substance unit is set to mmol.</p>\n"
1639 "<p>On export both species should be exported with the hasOnlySubstanceUnits flag set to false and the expression for the event assignment should contain a reference to the global parameter.</p>\n"
1642 " <ListOfCompartments>\n"
1643 " <Compartment key=\"Compartment_0\" name=\"compartment\" simulationType=\"fixed\">\n"
1645 " </ListOfCompartments>\n"
1646 " <ListOfMetabolites>\n"
1647 " <Metabolite key=\"Metabolite_0\" name=\"A\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
1649 " <Metabolite key=\"Metabolite_1\" name=\"B\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
1651 " </ListOfMetabolites>\n"
1652 " <ListOfModelValues>\n"
1653 " <ModelValue key=\"ModelValue_0\" name=\"K\" simulationType=\"fixed\">\n"
1655 " </ListOfModelValues>\n"
1657 " <Event key=\"Event_0\" name=\"event\" delayAssignment=\"false\" >\n"
1658 " <TriggerExpression>\n"
1659 " <CN=Root,Model=New Model,Reference=Time> gt 2.0\n"
1660 " </TriggerExpression>\n"
1661 " <DelayExpression>\n"
1663 " </DelayExpression>\n"
1664 " <ListOfAssignments>\n"
1665 " <Assignment targetKey=\"Metabolite_0\">\n"
1667 " <CN=Root,Model=New Model,Vector=Values[K],Reference=Value>\n"
1670 " </ListOfAssignments>\n"
1672 " </ListOfEvents>\n"
1673 " <StateTemplate>\n"
1674 " <StateTemplateVariable objectReference=\"Model_0\"/>\n"
1675 " <StateTemplateVariable objectReference=\"Metabolite_0\"/>\n"
1676 " <StateTemplateVariable objectReference=\"Metabolite_1\"/>\n"
1677 " <StateTemplateVariable objectReference=\"ModelValue_0\"/>\n"
1678 " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
1679 " </StateTemplate>\n"
1680 " <InitialState type=\"initialState\">\n"
1681 " 0 1.2044283e+21 6.022141500000001e+20 2 1\n"
1682 " </InitialState>\n"
1695 CPPUNIT_ASSERT(result ==
true);
1696 CPPUNIT_ASSERT(pDataModel->
getModel() != NULL);
1699 CPPUNIT_ASSERT(pDocument != NULL);
1700 CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1701 CPPUNIT_ASSERT(pDocument->getVersion() == 4);
1702 Model* pModel = pDocument->getModel();
1703 CPPUNIT_ASSERT(pModel != NULL);
1705 UnitDefinition* pUDef = pModel->getUnitDefinition(
"time");
1712 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1713 pUnit = pUDef->getUnit(0);
1714 CPPUNIT_ASSERT(pUnit != NULL);
1715 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1716 CPPUNIT_ASSERT(pUnit->getScale() == 0);
1717 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1718 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1721 pUDef = pModel->getUnitDefinition(
"substance");
1722 CPPUNIT_ASSERT(pUDef != NULL);
1723 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1724 pUnit = pUDef->getUnit(0);
1725 CPPUNIT_ASSERT(pUnit != NULL);
1726 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1727 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1728 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1729 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1730 pUDef = pModel->getUnitDefinition(
"volume");
1731 CPPUNIT_ASSERT(pUDef != NULL);
1732 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1733 pUnit = pUDef->getUnit(0);
1734 CPPUNIT_ASSERT(pUnit != NULL);
1735 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1736 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1737 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1738 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1741 CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1742 CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1743 Parameter* pParameter1 = pModel->getParameter(0);
1744 CPPUNIT_ASSERT(pParameter1 != NULL);
1745 CPPUNIT_ASSERT(pParameter1->getName() ==
"K");
1746 CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1747 Species* pSpecies1 = pModel->getSpecies(0);
1748 CPPUNIT_ASSERT(pSpecies1->getName() ==
"A");
1749 Species* pSpecies2 = pModel->getSpecies(1);
1750 CPPUNIT_ASSERT(pSpecies2->getName() ==
"B");
1751 CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1752 CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1753 CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1754 Event* pEvent = pModel->getEvent(0);
1755 CPPUNIT_ASSERT(pEvent != NULL);
1757 CPPUNIT_ASSERT(pEvent->isSetTrigger());
1758 Trigger* pTrigger = pEvent->getTrigger();
1759 CPPUNIT_ASSERT(pTrigger != NULL);
1760 CPPUNIT_ASSERT(pTrigger->isSetMath());
1761 const ASTNode* pMath = pTrigger->getMath();
1762 CPPUNIT_ASSERT(pMath != NULL);
1763 CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1764 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1765 const ASTNode* pChild = pMath->getChild(0);
1766 CPPUNIT_ASSERT(pChild != NULL);
1767 CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1768 pChild = pMath->getChild(1);
1769 CPPUNIT_ASSERT(pChild != NULL);
1770 CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1771 CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1773 CPPUNIT_ASSERT(pEvent->isSetDelay() ==
false);
1774 CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() ==
true);
1775 Delay* pDelay = pEvent->getDelay();
1776 CPPUNIT_ASSERT(pDelay == NULL);
1778 CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1779 EventAssignment* pEA = pEvent->getEventAssignment(0);
1780 CPPUNIT_ASSERT(pEA != NULL);
1781 CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1782 pMath = pEA->getMath();
1783 CPPUNIT_ASSERT(pMath != NULL);
1786 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1787 CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1798 CPPUNIT_ASSERT(result ==
true);
1799 CPPUNIT_ASSERT(pDataModel->
getModel() != NULL);
1802 CPPUNIT_ASSERT(pDocument != NULL);
1803 CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1804 CPPUNIT_ASSERT(pDocument->getVersion() == 1);
1805 Model* pModel = pDocument->getModel();
1806 CPPUNIT_ASSERT(pModel != NULL);
1808 UnitDefinition* pUDef = pModel->getUnitDefinition(
"time");
1815 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1816 pUnit = pUDef->getUnit(0);
1817 CPPUNIT_ASSERT(pUnit != NULL);
1818 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1819 CPPUNIT_ASSERT(pUnit->getScale() == 0);
1820 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1821 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1824 pUDef = pModel->getUnitDefinition(
"substance");
1825 CPPUNIT_ASSERT(pUDef != NULL);
1826 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1827 pUnit = pUDef->getUnit(0);
1828 CPPUNIT_ASSERT(pUnit != NULL);
1829 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1830 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1831 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1832 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1833 pUDef = pModel->getUnitDefinition(
"volume");
1834 CPPUNIT_ASSERT(pUDef != NULL);
1835 CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1836 pUnit = pUDef->getUnit(0);
1837 CPPUNIT_ASSERT(pUnit != NULL);
1838 CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1839 CPPUNIT_ASSERT(pUnit->getScale() == -3);
1840 CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1841 CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1844 CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1845 CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1846 Parameter* pParameter1 = pModel->getParameter(0);
1847 CPPUNIT_ASSERT(pParameter1 != NULL);
1848 CPPUNIT_ASSERT(pParameter1->getName() ==
"K");
1849 CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1850 Species* pSpecies1 = pModel->getSpecies(0);
1851 CPPUNIT_ASSERT(pSpecies1->getName() ==
"A");
1852 Species* pSpecies2 = pModel->getSpecies(1);
1853 CPPUNIT_ASSERT(pSpecies2->getName() ==
"B");
1854 CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1855 CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1856 CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1857 Event* pEvent = pModel->getEvent(0);
1858 CPPUNIT_ASSERT(pEvent != NULL);
1860 CPPUNIT_ASSERT(pEvent->isSetTrigger());
1861 Trigger* pTrigger = pEvent->getTrigger();
1862 CPPUNIT_ASSERT(pTrigger != NULL);
1863 CPPUNIT_ASSERT(pTrigger->isSetMath());
1864 const ASTNode* pMath = pTrigger->getMath();
1865 CPPUNIT_ASSERT(pMath != NULL);
1866 CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1867 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1868 const ASTNode* pChild = pMath->getChild(0);
1869 CPPUNIT_ASSERT(pChild != NULL);
1870 CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1871 pChild = pMath->getChild(1);
1872 CPPUNIT_ASSERT(pChild != NULL);
1873 CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1874 CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1876 CPPUNIT_ASSERT(pEvent->isSetDelay() ==
false);
1877 CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() ==
true);
1878 Delay* pDelay = pEvent->getDelay();
1879 CPPUNIT_ASSERT(pDelay == NULL);
1881 CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1882 EventAssignment* pEA = pEvent->getEventAssignment(0);
1883 CPPUNIT_ASSERT(pEA != NULL);
1884 CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1885 pMath = pEA->getMath();
1886 CPPUNIT_ASSERT(pMath != NULL);
1889 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1890 CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1903 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1904 "<!-- generated with COPASI 4.4.26 (Debug) (http://www.copasi.org) at 2008-06-12 09:00:21 UTC -->\n"
1905 "<COPASI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.copasi.org/static/schema.xsd\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"26\">\n"
1906 " <Model key=\"Model_0\" name=\"New Model\" timeUnit=\"s\" volumeUnit=\"ml\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
1908 " <html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:9pt;font-family:Sans Serif\">\n"
1909 "<p>Simple model with two species and one global parameter. The compartment is fixed and one species is changed by an event assignment.</p>\n"
1910 "<p>The substance unit is set to mmol.</p>\n"
1911 "<p>On export both species should be exported with the hasOnlySubstanceUnits flag set to false and the expression for the event assignment should contain a reference to the global parameter.</p>\n"
1914 " <ListOfCompartments>\n"
1915 " <Compartment key=\"Compartment_0\" name=\"compartment\" simulationType=\"fixed\">\n"
1917 " </ListOfCompartments>\n"
1918 " <ListOfMetabolites>\n"
1919 " <Metabolite key=\"Metabolite_0\" name=\"A\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
1921 " <Metabolite key=\"Metabolite_1\" name=\"B\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
1923 " </ListOfMetabolites>\n"
1924 " <ListOfModelValues>\n"
1925 " <ModelValue key=\"ModelValue_0\" name=\"K\" simulationType=\"fixed\">\n"
1927 " </ListOfModelValues>\n"
1929 " <Event key=\"Event_0\" name=\"event\" delayAssignment=\"true\" >\n"
1930 " <TriggerExpression>\n"
1931 " <CN=Root,Model=New Model,Reference=Time> gt 2.0\n"
1932 " </TriggerExpression>\n"
1933 " <ListOfAssignments>\n"
1934 " <Assignment targetKey=\"Metabolite_0\">\n"
1936 " <CN=Root,Model=New Model,Vector=Values[K],Reference=Value>\n"
1939 " </ListOfAssignments>\n"
1941 " </ListOfEvents>\n"
1942 " <StateTemplate>\n"
1943 " <StateTemplateVariable objectReference=\"Model_0\"/>\n"
1944 " <StateTemplateVariable objectReference=\"Metabolite_0\"/>\n"
1945 " <StateTemplateVariable objectReference=\"Metabolite_1\"/>\n"
1946 " <StateTemplateVariable objectReference=\"ModelValue_0\"/>\n"
1947 " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
1948 " </StateTemplate>\n"
1949 " <InitialState type=\"initialState\">\n"
1950 " 0 1.2044283e+21 6.022141500000001e+20 2 1\n"
1951 " </InitialState>\n"
Header file of class CExpression.
SBMLDocument * getCurrentSBMLDocument()
void test_import_delayAssignment_2()
Header file of class CModelEntity and CModelValue.
void test_export_delayAssignment_1()
const std::string & getObjectName() const
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
const CRegisteredObjectName & getObjectCN() const
static const char * MODEL_STRING5
const C_FLOAT64 & getValue() const
const Type & getType() const
const size_t & getNumber() const
static const char * MODEL_STRING4
void test_import_delayAssignment_1()
static const char * MODEL_STRING103
void test_export_delayAssignment_6()
void test_import_delayAssignment_3()
void test_import_delayAssignment_6()
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
static Type type(const Type &type)
static const char * MODEL_STRING1
void test_import_delayAssignment_7()
void test_import_delayAssignment_8()
void test_export_delayAssignment_3()
static CCopasiDataModel * addDatamodel()
static Type subType(const Type &type)
static const char * MODEL_STRING3
static const char * MODEL_STRING6
static CCopasiDataModel * pCOPASIDATAMODEL
static CCopasiMessage getLastMessage()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static const char * MODEL_STRING101
void test_export_delayAssignment_2()
static void init(int argc, char *argv[], const bool &withGui=false)
void test_import_delayAssignment_4()
static const char * MODEL_STRING2
static const char * MODEL_STRING102
static const char * MODEL_STRING7
CCopasiNode< Data > * getChild()
static const char * MODEL_STRING8
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
void test_export_delayAssignment_4()
CCopasiContainer * getObjectParent() const
void test_export_delayAssignment_5()
void test_import_delayAssignment_5()