当前位置: 首页>>代码示例>>Java>>正文


Java ASTNode.getType方法代码示例

本文整理汇总了Java中org.sbml.jsbml.ASTNode.getType方法的典型用法代码示例。如果您正苦于以下问题:Java ASTNode.getType方法的具体用法?Java ASTNode.getType怎么用?Java ASTNode.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sbml.jsbml.ASTNode的用法示例。


在下文中一共展示了ASTNode.getType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setTimeToT

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
/**
 * Recursive function to change time variable to t
 */
public static void setTimeToT(ASTNode node)
{
	if (node == null)
	{
		return;
	}
	if (node.getType() == ASTNode.Type.NAME_TIME)
	{
		if (node.getName()==null || !node.getName().equals("t") || !node.getName().equals("time"))
		{
			node.setName("t");
		}
	}
	else if (node.getType() == ASTNode.Type.NAME_AVOGADRO)
	{
		node.setName("avogadro");
	}
	for (int c = 0; c < node.getChildCount(); c++)
	{
		setTimeToT(node.getChild(c));
	}
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:26,代码来源:SBMLutilities.java

示例2: removePreset

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
public static ASTNode removePreset(ASTNode math, String place)
{
	if (math.getType() == ASTNode.Type.LOGICAL_AND)
	{
		ASTNode rightChild = math.getRightChild();
		if (rightChild.getType() == ASTNode.Type.RELATIONAL_EQ && rightChild.getLeftChild().toFormula().equals(place))
		{
			return deepCopy(math.getLeftChild());
		}
	}
	for (int i = 0; i < math.getChildCount(); i++)
	{
		ASTNode child = removePreset(math.getChild(i), place);
		math.replaceChild(i, child);
	}
	return deepCopy(math);
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:18,代码来源:SBMLutilities.java

示例3: removeBoolean

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
public static ASTNode removeBoolean(ASTNode math, String boolVar)
{
	if (math == null)
	{
		return null;
	}
	if (math.getType() == ASTNode.Type.RELATIONAL_EQ)
	{
		if (math.getLeftChild().isSetName() && math.getLeftChild().getName().equals(boolVar))
		{
			return deepCopy(math.getLeftChild());
		}
	}
	for (int i = 0; i < math.getChildCount(); i++)
	{
		ASTNode child = removeBoolean(math.getChild(i), boolVar);
		math.replaceChild(i, child);
	}
	return deepCopy(math);
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:21,代码来源:SBMLutilities.java

示例4: splitMath

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
public static ASTNode[] splitMath(ASTNode math)
{
	ASTNode plus = new ASTNode(Type.PLUS);
	ASTNode minus = new ASTNode(Type.PLUS);
	ASTNode[] result = new ASTNode[] { plus, minus };
	List<ASTNode> nodes = RateSplitterInterpreter.parseASTNode(math);
	for (ASTNode node : nodes)
	{
		if (node.getType() == ASTNode.Type.MINUS)
		{
			minus.addChild(node.getChild(0));
		}
		else
		{
			plus.addChild(node);
		}
	}

	return plus.getChildCount() > 0 && minus.getChildCount() > 0 ? result : null;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:21,代码来源:HierarchicalUtilities.java

示例5: removeBooleanAssign

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
public String removeBooleanAssign(ASTNode math) {
	if (math.getType() == ASTNode.Type.FUNCTION_PIECEWISE && math.getChildCount() > 1) {
		ASTNode result = math.getChild(1);
		for (int j = 0; j < sbml.getModel().getParameterCount(); j++) {
			Parameter parameter = sbml.getModel().getParameter(j);
			if (SBMLutilities.isBoolean(parameter)) {
				result = SBMLutilities.removeBoolean(result,parameter.getId());
			}
		}
		return SBMLutilities.myFormulaToString(result);
	}
	return SBMLutilities.myFormulaToString(math);
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:14,代码来源:BioModel.java

示例6: isBoolean

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
public static boolean isBoolean(SBMLDocument document, ASTNode node)
{
	if (node == null)
	{
		return false;
	}
	else if (node.isBoolean())
	{
		return true;
	}
	else if (node.getType() == ASTNode.Type.FUNCTION)
	{
		FunctionDefinition fd = document.getModel().getFunctionDefinition(node.getName());
		if (fd != null && fd.isSetMath())
		{
			return isBoolean(document, fd.getMath().getRightChild());
		}
		return false;
	}
	else if (node.getType() == ASTNode.Type.FUNCTION_PIECEWISE)
	{
		for (int c = 0; c < node.getChildCount(); c += 2)
		{
			if (!isBoolean(document, node.getChild(c)))
			{
				return false;
			}
		}
		return true;
	}
	return false;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:33,代码来源:SBMLutilities.java

示例7: SBMLMathToBoolLPNString

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
public static String SBMLMathToBoolLPNString(ASTNode math, HashMap<String, Integer> constants, ArrayList<String> booleans)
{
	if (math.getType() == ASTNode.Type.FUNCTION_PIECEWISE && math.getChildCount() > 1)
	{
		return SBMLMathToLPNString(math.getChild(1), constants, booleans);
	}
	return SBMLMathToLPNString(math, constants, booleans);
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:9,代码来源:SBMLutilities.java

示例8: evaluateBooleanMathML

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
/**
 * Evaluates a boolean Math ML expression
 * 
 * @param node  MathML node that is a boolean expression
 * @param t     time, the only parameter used in the expression
 * 
 * @return the boolean result of evaluating the expression
 */
private boolean evaluateBooleanMathML(ASTNode node, double t) {
    
    boolean result = false;
    
    switch(node.getType()) {
    
    case LOGICAL_AND:
        result = evaluateBooleanMathML(
                node.getLeftChild(), t) && evaluateBooleanMathML(node.getRightChild(), t);
        return result;
        
    case RELATIONAL_GEQ:
        result = evaluateMathML(
                node.getLeftChild(), t) >= evaluateMathML(node.getRightChild(), t);
        return result;
        
    case RELATIONAL_LEQ:
        result = evaluateMathML(
                node.getLeftChild(), t) <= evaluateMathML(node.getRightChild(), t);
        return result;
        
    default:
        throw new RuntimeException(
                "No code to handle boolean expression of type " + node.getType());
    }
}
 
开发者ID:allyhume,项目名称:SBMLDataTools,代码行数:35,代码来源:SBMLTimeCourseDataHelperTest.java

示例9: replaceFunctionDefinition

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
private ASTNode replaceFunctionDefinition(ASTNode equation, ListOf<FunctionDefinition> functions) {
	if (equation.getType() == ASTNode.Type.FUNCTION) {
		FunctionDefinition fd = functions.get(equation.getName());
		ASTNode newNode = fd.getBody();
		for (int i = 0; i < fd.getArgumentCount(); i++) {
			newNode = replace(fd.getArgument(i).getName(), equation.getChild(i), newNode);
		}
		return newNode;
	}
	for (int i = 0; i < equation.getChildCount(); i++) {
		equation.replaceChild(i, replaceFunctionDefinition(equation.getChild(i), functions));
	}
	return equation;
}
 
开发者ID:dreal,项目名称:biology,代码行数:15,代码来源:ODEModel.java

示例10: replace

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
private ASTNode replace(String variable, ASTNode replacement, ASTNode equation) {
	if (equation.getType() == ASTNode.Type.NAME && equation.getName().equals(variable)) {
		return new ASTNode(replacement);
	}
	for (int i = 0; i < equation.getChildCount(); i++) {
		equation.replaceChild(i,
				replace(variable, new ASTNode(replacement), equation.getChild(i)));
	}
	return equation;
}
 
开发者ID:dreal,项目名称:biology,代码行数:11,代码来源:ODEModel.java

示例11: setTimeAndTrigVar

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
/**
 * Recursive function to set time and trig functions
 */
public static void setTimeAndTrigVar(ASTNode node)
{
	if (node.getType() == ASTNode.Type.NAME)
	{
		if (node.getName().equals("t"))
		{
			node.setType(ASTNode.Type.NAME_TIME);
			node.setName("t");
		}
		else if (node.getName().equals("time"))
		{
			node.setType(ASTNode.Type.NAME_TIME);
		}
		else if (node.getName().equals("avogadro"))
		{
			node.setType(ASTNode.Type.NAME_AVOGADRO);
		}
	}
	if (node.getType() == ASTNode.Type.FUNCTION)
	{
		if (node.getName().equals("acot"))
		{
			node.setType(ASTNode.Type.FUNCTION_ARCCOT);
		}
		else if (node.getName().equals("acoth"))
		{
			node.setType(ASTNode.Type.FUNCTION_ARCCOTH);
		}
		else if (node.getName().equals("acsc"))
		{
			node.setType(ASTNode.Type.FUNCTION_ARCCSC);
		}
		else if (node.getName().equals("acsch"))
		{
			node.setType(ASTNode.Type.FUNCTION_ARCCSCH);
		}
		else if (node.getName().equals("asec"))
		{
			node.setType(ASTNode.Type.FUNCTION_ARCSEC);
		}
		else if (node.getName().equals("asech"))
		{
			node.setType(ASTNode.Type.FUNCTION_ARCSECH);
		}
		else if (node.getName().equals("acosh"))
		{
			node.setType(ASTNode.Type.FUNCTION_ARCCOSH);
		}
		else if (node.getName().equals("asinh"))
		{
			node.setType(ASTNode.Type.FUNCTION_ARCSINH);
		}
		else if (node.getName().equals("atanh"))
		{
			node.setType(ASTNode.Type.FUNCTION_ARCTANH);
		}
	}

	for (int c = 0; c < node.getChildCount(); c++)
	{
		setTimeAndTrigVar(node.getChild(c));
	}
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:67,代码来源:SBMLutilities.java

示例12: evaluateMathML

import org.sbml.jsbml.ASTNode; //导入方法依赖的package包/类
/**
 * Helper method to evaluate a MathML equation at a given time.
 * 
 * @param node   MathML equation
 * @param t      time, the only parameter to the equation
 * 
 * @return the value of the equation at the specified time
 */
private double evaluateMathML(ASTNode node, double t) {
    
    double result;
    
    switch(node.getType()) {
    
    case FUNCTION_PIECEWISE:
        for (int i=0; i<node.getNumChildren()/2; ++i ) {
            
            if (evaluateBooleanMathML(node.getChild(i*2+1), t)) {
                return evaluateMathML(node.getChild(i*2), t);
            }
        }
        // error no match found
        throw new RuntimeException("No match found in the ranges of the piecewise");
        
    case POWER:
        result = Math.pow(evaluateMathML(node.getLeftChild(), t),
                        evaluateMathML(node.getRightChild(), t));
        return result;
    
    case TIMES:
        result = 1;
        for (int i=0; i<node.getNumChildren(); ++i) {
            result *= evaluateMathML(node.getChild(i), t); 
        }
        return result;
        
    case PLUS:
        result = 0;
        for (int i=0; i<node.getNumChildren(); ++i) {
            result += evaluateMathML(node.getChild(i), t); 
        }
        return result;
        
    case MINUS:
        result = evaluateMathML(node.getChild(0), t);
        for (int i=1; i<node.getNumChildren(); ++i) {
            result -= evaluateMathML(node.getChild(i), t); 
        }
        return result;

    case NAME_TIME:
        result = t;
        return result;
        
    case REAL:
    case INTEGER:
        result = Double.parseDouble(node.toString());
        return result;
        
    default:
        // Should probably throw an exception
        throw new RuntimeException("No rule for type: " + node.getType());
    }
}
 
开发者ID:allyhume,项目名称:SBMLDataTools,代码行数:65,代码来源:SBMLTimeCourseDataHelperTest.java


注:本文中的org.sbml.jsbml.ASTNode.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。