if (values.containsKey(atKI)) { double d = values.get(atKI).doubleValue(); if (d < p.getValue()) values.put(atKI, Double.valueOf(p.getValue())); } else { values.put(atKI, Double.valueOf(p.getValue())); if (values.containsKey(atKM)) { double d = values.get(atKM).doubleValue(); if (d < p.getValue()) values.put(atKM, Double.valueOf(p.getValue())); } else { values.put(atKM, Double.valueOf(p.getValue())); if (values.containsKey(atTN)) { double d = values.get(atTN).doubleValue(); if (d < p.getValue()) values.put(atTN, Double.valueOf(p.getValue())); } else { values.put(atTN, Double.valueOf(p.getValue()));
@Override public Map<String, String> writeXMLAttributes() { Map<String, String> attributes = super.writeXMLAttributes(); if (isSetValue()) { attributes.put("value", StringTools.toString(Locale.ENGLISH, getValue())); } if (isSetUnits()) { attributes.put("units", getUnits()); } if (isSetConstant() && (getLevel() > 1)) { attributes.put("constant", Boolean.toString(getConstant())); } return attributes; }
/** * Maps a dimension id to the size of the dimension object. * * @param model * @param arraysSBasePlugin * @return */ public static Map<String, Double> getDimensionSizes(Model model, ArraysSBasePlugin arraysSBasePlugin) { Map<String, Double> dimensionValue = new HashMap<String, Double>(); if (arraysSBasePlugin == null) { return dimensionValue; } for (Dimension dim : arraysSBasePlugin.getListOfDimensions()) { if (dim.isSetId()) { Parameter size = model.getParameter(dim.getSize()); if (size != null) { dimensionValue.put(dim.getId(), size.getValue()); } } } return dimensionValue; }
/** * @param arraysPlugin * @param node * @return */ private ASTNode constructVector(ArraysSBasePlugin arraysPlugin, ASTNode node) { Dimension dim = arraysPlugin.getDimensionByArrayDimension(0); Parameter p = model.getParameter(dim.getSize()); double size = p.getValue(); List<ASTNode> vector = new ArrayList<ASTNode>((int) size); for (int j = 0; j < size; ++j) { vector.add(node.clone()); } vector(vector); ASTNode vectorNode = getNode(); for (int i = 1; i < arraysPlugin.getDimensionCount(); ++i) { dim = arraysPlugin.getDimensionByArrayDimension(i); p = model.getParameter(dim.getSize()); size = p.getValue(); vector = new ArrayList<ASTNode>((int) size); for (int j = 0; j < size; ++j) { vector.add(vectorNode); } vector(vector); vectorNode = getNode(); } return vectorNode; }
/** * Gets the size of a Dimension object. * * @param model * @param dimension * @return */ public static int getSize(Model model, Dimension dimension) { if (dimension == null) { return 0; } String sizeRef = dimension.getSize(); Parameter param = model.getParameter(sizeRef); if (param == null || !param.isSetValue()) { throw new SBMLException(); } return (int) param.getValue(); }
/** * @param arraysPlugin * @param quantity * @return */ private ASTNode constructVector(ArraysSBasePlugin arraysPlugin, Quantity quantity) { double value = quantity.getValue(); Dimension dim = arraysPlugin.getDimensionByArrayDimension(0); Parameter p = model.getParameter(dim.getSize()); double size = p.getValue(); List<ASTNode> vector = new ArrayList<ASTNode>((int) size); for (int j = 0; j < size; ++j) { vector.add(new ASTNode(value)); } vector(vector); ASTNode vectorNode = getNode(); for (int i = 1; i < arraysPlugin.getDimensionCount(); ++i) { dim = arraysPlugin.getDimensionByArrayDimension(i); p = model.getParameter(dim.getSize()); size = p.getValue(); vector = new ArrayList<ASTNode>((int) size); for (int j = 0; j < size; ++j) { vector.add(vectorNode); } vector(vector); vectorNode = getNode(); } return vectorNode; }
if (param.getValue() % 1 != 0) { String shortMsg = "The attribute arrays:size of a Dimension object should point to a parameter containing an integer value."; logDimensionSizeValueInconsistency(shortMsg); if (param.getValue() < 0) { String shortMsg = MessageFormat.format("The attribute arrays:size of a Dimension object should point to a parameter that has a non-negative integer value but {0} has a negative value.", dim.toString()); logDimensionSizeValueInconsistency(shortMsg);
/** * Checks if adding an {@link Index} object to a parent * {@link SBase} object for referencing another {@link SBase} object does not * cause out-of-bounds issues. * * @param model * @param reference * @param arrayDim * @param math * @param dimSizes * @return */ public static boolean evaluateIndexBounds(Model model, SBase reference, int arrayDim, ASTNode math, Map<String, Double> dimSizes) { ArraysSBasePlugin refSbasePlugin = (ArraysSBasePlugin) reference.getExtension(ArraysConstants.shortLabel); Dimension dim = refSbasePlugin.getDimensionByArrayDimension(arrayDim); if (dim == null) { return false; } Parameter paramSize = model.getParameter(dim.getSize()); if (paramSize == null) { return false; } double size = paramSize.getValue(); return evaluateBounds(dimSizes, math, size); }
return false; int actual = (int) p.getValue(); if (expected != actual) { return false;
continue; sizeByLevel.put(level+maxDim-dim.getArrayDimension(), (int) p.getValue());
double size = param.getValue(); result &= evaluateBounds(dimensionSizes, index, size); } else {