public void test_InitialAssignment_setMath() { ASTNode math = libsbml.parseFormula("2 * k"); string formula; ASTNode math1; IA.setMath(math); math1 = IA.getMath(); assertTrue(math1 != null); formula = libsbml.formulaToString(math1); assertTrue(formula != null); assertTrue(("2 * k" == formula)); assertTrue(IA.getMath() != math); assertEquals(true, IA.isSetMath()); IA.setMath(IA.getMath()); math1 = IA.getMath(); assertTrue(math1 != null); formula = libsbml.formulaToString(math1); assertTrue(formula != null); assertTrue(("2 * k" == formula)); assertTrue(IA.getMath() != math); IA.setMath(null); assertEquals(false, IA.isSetMath()); if (IA.getMath() != null) { ; } { } math = null; }
public void test_InitialAssignment_setMath1() { ASTNode math = libsbml.parseFormula("2 * k"); int i = E.setMath(math); assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS); assertTrue(E.getMath() != math); assertEquals(true, E.isSetMath()); i = E.setMath(null); assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS); assertTrue(E.getMath() == null); assertEquals(false, E.isSetMath()); math = null; }
public void test_InitialAssignment() { InitialAssignment ia = new InitialAssignment(2, 4); assertEquals(false, (ia.hasRequiredElements())); ia.setMath(libsbml.parseFormula("ia")); assertEquals(true, ia.hasRequiredElements()); ia = null; }
public void test_InitialAssignment_parent_add() { InitialAssignment ia = new InitialAssignment(2, 4); Model m = new Model(2, 4); ia.setSymbol("c"); ia.setMath(libsbml.parseFormula("9")); m.addInitialAssignment(ia); ia = null; ListOf lo = m.getListOfInitialAssignments(); assertTrue(lo == m.getInitialAssignment(0).getParentSBMLObject()); assertTrue(m == lo.getParentSBMLObject()); }
public void test_Model_addInitialAssignment2() { Model m = new Model(2, 2); InitialAssignment ia = new InitialAssignment(2, 3); ia.setSymbol("i"); ia.setMath(libsbml.parseFormula("gg")); int i = m.addInitialAssignment(ia); assertTrue(i == libsbml.LIBSBML_VERSION_MISMATCH); assertTrue(m.getNumInitialAssignments() == 0); ia = null; m = null; }
public void test_Model_addInitialAssignment1() { Model m = new Model(2, 2); InitialAssignment ia = new InitialAssignment(2, 2); int i = m.addInitialAssignment(ia); assertTrue(i == libsbml.LIBSBML_INVALID_OBJECT); ia.setSymbol("i"); i = m.addInitialAssignment(ia); assertTrue(i == libsbml.LIBSBML_INVALID_OBJECT); ia.setMath(libsbml.parseFormula("gg")); i = m.addInitialAssignment(ia); assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS); assertTrue(m.getNumInitialAssignments() == 1); ia = null; m = null; }
public void test_InitialAssignment_ancestor_add() { InitialAssignment ia = new InitialAssignment(2, 4); Model m = new Model(2, 4); ia.setSymbol("c"); ia.setMath(libsbml.parseFormula("9")); m.addInitialAssignment(ia); ia = null; ListOf lo = m.getListOfInitialAssignments(); InitialAssignment obj = m.getInitialAssignment(0); assertTrue(obj.getAncestorOfType(libsbml.SBML_MODEL) == m); assertTrue(obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo); assertTrue(obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null); assertTrue(obj.getAncestorOfType(libsbml.SBML_EVENT) == null); }
public void test_Model_addInitialAssignment4() { Model m = new Model(2, 2); InitialAssignment ia = new InitialAssignment(2, 2); ia.setSymbol("ia"); ia.setMath(libsbml.parseFormula("a+b")); InitialAssignment ia1 = new InitialAssignment(2, 2); ia1.setSymbol("ia"); ia1.setMath(libsbml.parseFormula("a+b")); int i = m.addInitialAssignment(ia); assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS); assertTrue(m.getNumInitialAssignments() == 1); i = m.addInitialAssignment(ia1); assertTrue(i == libsbml.LIBSBML_DUPLICATE_OBJECT_ID); assertTrue(m.getNumInitialAssignments() == 1); ia = null; ia1 = null; m = null; }
public static void Main(string[] args) { ArraysPkgNamespaces arraysNs = new ArraysPkgNamespaces(); SBMLDocument doc = new SBMLDocument(arraysNs); doc.setPackageRequired("arrays", true); Model model = doc.createModel(); // create parameters Parameter param = model.createParameter(); param.setId("n"); param.setValue(10); param.setConstant(true); param = model.createParameter(); param.setId("m"); param.setValue(10); param.setConstant(true); param = model.createParameter(); param.setId("x"); param.setValue(5.7); param.setConstant(true); ArraysSBasePlugin paramPlugin = (ArraysSBasePlugin)param.getPlugin("arrays"); Dimension dim = paramPlugin.createDimension(); dim.setId("i"); dim.setSize("n"); param = model.createParameter(); param.setId("y"); param.setConstant(false); paramPlugin = (ArraysSBasePlugin)param.getPlugin("arrays"); dim = paramPlugin.createDimension(); dim.setId("i"); dim.setSize("n"); param = model.createParameter(); param.setId("z"); param.setConstant(false); paramPlugin = (ArraysSBasePlugin)param.getPlugin("arrays"); dim = paramPlugin.createDimension(); dim.setId("i"); dim.setSize("n"); // create initial assignments InitialAssignment assignment = model.createInitialAssignment(); assignment.setSymbol("y"); ASTNode ast = new ASTNode(libsbml.AST_REAL); ast.setValue(3.2); assignment.setMath(ast); assignment = model.createInitialAssignment(); assignment.setSymbol("z"); ast = new ASTNode(libsbml.AST_REAL); ast.setValue(5.7); assignment.setMath(ast); ArraysSBasePlugin assignmentPlugin = (ArraysSBasePlugin)assignment.getPlugin("arrays"); dim = assignmentPlugin.createDimension(); dim.setId("i"); dim.setSize("m"); Index index = assignmentPlugin.createIndex(); ASTNode newAst = new ASTNode(libsbml.AST_FUNCTION); newAst.setName("selector"); ASTNode ci = new ASTNode(libsbml.AST_NAME); ci.setName("z"); newAst.addChild(ci); ci = new ASTNode(libsbml.AST_NAME); ci.setName("i"); newAst.addChild(ci); index.setMath(newAst); assignment = model.createInitialAssignment(); assignment.setSymbol("z"); ast = new ASTNode(libsbml.AST_REAL); ast.setValue(3.2); assignment.setMath(ast); assignmentPlugin = (ArraysSBasePlugin)assignment.getPlugin("arrays"); dim = assignmentPlugin.createDimension(); dim.setId("i"); dim.setSize("m"); index = assignmentPlugin.createIndex(); newAst = new ASTNode(libsbml.AST_LINEAR_ALGEBRA_SELECTOR); ci = new ASTNode(libsbml.AST_NAME); ci.setName("z"); newAst.addChild(ci); ASTNode plus = new ASTNode(libsbml.AST_PLUS); ci = new ASTNode(libsbml.AST_NAME); ci.setName("i"); plus.addChild(ci); ci = new ASTNode(libsbml.AST_NAME); ci.setName("m"); plus.addChild(ci); newAst.addChild(plus); index.setMath(newAst); libsbml.writeSBMLToFile(doc, "arrays2.xml"); }