Search in sources :

Example 6 with ColumnDescription

use of cbit.vcell.util.ColumnDescription in project vcell by virtualcell.

the class ODESolverPlotSpecificationPanel method initConnections.

/**
 * Initializes connections
 * @exception java.lang.Exception The exception description.
 */
@SuppressWarnings({ "serial", "unchecked" })
private void initConnections() throws java.lang.Exception {
    // user code begin {1}
    // user code end
    getFilterPanel().addPropertyChangeListener(ivjEventHandler);
    getYAxisChoice().addListSelectionListener(ivjEventHandler);
    this.addPropertyChangeListener(ivjEventHandler);
    getXAxisComboBox_frm().addItemListener(ivjEventHandler);
    getLogSensCheckbox().addActionListener(ivjEventHandler);
    getSensitivityParameterSlider().addChangeListener(ivjEventHandler);
    connPtoP1SetTarget();
    connPtoP3SetTarget();
    getYAxisChoice().setCellRenderer(new DefaultListCellRenderer() {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            ODEDataInterface mdi = getMyDataInterface();
            if (mdi == null) {
                return this;
            }
            String varName = (String) value;
            ColumnDescription cd = null;
            try {
                cd = mdi.getColumnDescription(varName);
            } catch (ObjectNotFoundException e) {
                e.printStackTrace();
            }
            if (cd instanceof FunctionColumnDescription && ((FunctionColumnDescription) cd).getIsUserDefined()) {
                if (function_icon == null) {
                    function_icon = new ImageIcon(getClass().getResource("/icons/function_icon.png"));
                }
                setIcon(function_icon);
            }
            if (mdi.getDataSymbolMetadataResolver() != null && mdi.getDataSymbolMetadataResolver().getDataSymbolMetadata(varName) != null) {
                DataSymbolMetadata dsm = mdi.getDataSymbolMetadataResolver().getDataSymbolMetadata(varName);
                String tooltipString = dsm.tooltipString;
                if (tooltipString == null) {
                    tooltipString = varName;
                }
                setToolTipText(tooltipString);
            }
            return this;
        }
    });
}
Also used : ImageIcon(javax.swing.ImageIcon) ColumnDescription(cbit.vcell.util.ColumnDescription) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) DataSymbolMetadata(cbit.vcell.solver.DataSymbolMetadata) ODEDataInterface(cbit.vcell.client.data.ODEDataInterface) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) Component(java.awt.Component) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) JList(javax.swing.JList)

Example 7 with ColumnDescription

use of cbit.vcell.util.ColumnDescription in project vcell by virtualcell.

the class MathTestingUtilities method compareUnEqualResultSets.

/**
 * Insert the method's description here.
 * Creation date: (1/17/2003 3:48:36 PM)
 * @param testResultSet cbit.vcell.solver.ode.ODESolverResultSet
 * @param referenceResultSet cbit.vcell.solver.ode.ODESolverResultSet
 */
public static SimulationComparisonSummary compareUnEqualResultSets(ODESolverResultSet testResultSet, ODESolverResultSet referenceResultSet, String[] varsToTest, double absErrorThreshold, double relErrorThreshold, int interpolationOrder) throws Exception {
    if (varsToTest == null) {
        throw new IllegalArgumentException("varsToTest must not be null");
    }
    SimulationComparisonSummary simComparisonSummary = new SimulationComparisonSummary();
    int testTimeOrHistogramIndex = testResultSet.findColumn(ReservedVariable.TIME.getName());
    int refTimeOrHistogramIndex = referenceResultSet.findColumn(ReservedVariable.TIME.getName());
    if (testTimeOrHistogramIndex < 0 && refTimeOrHistogramIndex < 0) {
        testTimeOrHistogramIndex = testResultSet.findColumn(SimDataConstants.HISTOGRAM_INDEX_NAME);
        refTimeOrHistogramIndex = referenceResultSet.findColumn(SimDataConstants.HISTOGRAM_INDEX_NAME);
    }
    double[] testRSTimes = testResultSet.extractColumn(testTimeOrHistogramIndex);
    double[] refRSTimes = referenceResultSet.extractColumn(refTimeOrHistogramIndex);
    for (int i = 0; i < varsToTest.length; i++) {
        int refRSIndex = referenceResultSet.findColumn(varsToTest[i]);
        if (refRSIndex == -1) {
            if (varsToTest[i].endsWith(AbstractMathMapping.MATH_VAR_SUFFIX_SPECIES_COUNT)) {
                String varNameWithoutCount = varsToTest[i].replace(AbstractMathMapping.MATH_VAR_SUFFIX_SPECIES_COUNT, "");
                refRSIndex = referenceResultSet.findColumn(varNameWithoutCount);
                if (refRSIndex == -1) {
                    throw new RuntimeException("neither variable '" + varsToTest[i] + "' nor '" + varNameWithoutCount + "' found in reference dataset");
                }
            } else {
                throw new RuntimeException("variable '" + varsToTest[i] + "' not found in reference dataset");
            }
        }
        ColumnDescription refColDesc = referenceResultSet.getColumnDescriptions(refRSIndex);
        double[] refData = referenceResultSet.extractColumn(refRSIndex);
        int testRSIndex = testResultSet.findColumn(varsToTest[i]);
        if (testRSIndex == -1) {
            throw new RuntimeException("variable '" + varsToTest[i] + "' not found in test dataset");
        }
        double[] testData = testResultSet.extractColumn(testRSIndex);
        // Resampling test data
        double[] resampledTestData = interpolateArray(refRSTimes, testRSTimes, testData, interpolationOrder);
        DataErrorSummary tempVar = new DataErrorSummary();
        for (int j = 0; j < refData.length; j++) {
            tempVar.addDataValues(refData[j], resampledTestData[j], refRSTimes[j], 0, absErrorThreshold, relErrorThreshold);
        }
        simComparisonSummary.addVariableComparisonSummary(new VariableComparisonSummary(refColDesc.getName(), tempVar.getMinRef(), tempVar.getMaxRef(), tempVar.getMaxAbsoluteError(), tempVar.getMaxRelativeError(), tempVar.getL2Norm(), tempVar.getTimeAtMaxAbsoluteError(), tempVar.getIndexAtMaxAbsoluteError(), tempVar.getTimeAtMaxRelativeError(), tempVar.getIndexAtMaxRelativeError()));
    }
    return simComparisonSummary;
}
Also used : ColumnDescription(cbit.vcell.util.ColumnDescription) ODESolverResultSetColumnDescription(cbit.vcell.math.ODESolverResultSetColumnDescription) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription)

Example 8 with ColumnDescription

use of cbit.vcell.util.ColumnDescription in project vcell by virtualcell.

the class MathTestingUtilities method compareResultSets.

/**
 * Insert the method's description here.
 * Creation date: (1/17/2003 3:48:36 PM)
 * @param testResultSet cbit.vcell.solver.ode.ODESolverResultSet
 * @param referenceResultSet cbit.vcell.solver.ode.ODESolverResultSet
 */
public static SimulationComparisonSummary compareResultSets(ODESolverResultSet testResultSet, ODESolverResultSet referenceResultSet, String[] varsToTest, String type, double absErrorThreshold, double relErrorThreshold) throws Exception {
    if (varsToTest == null) {
        throw new IllegalArgumentException("varsToTest must not be null");
    }
    SimulationComparisonSummary simComparisonSummary = new SimulationComparisonSummary();
    double[] timeData = referenceResultSet.extractColumn(referenceResultSet.findColumn(ODESolverResultSet.TIME_COLUMN));
    for (int i = 0; i < varsToTest.length; i++) {
        int refRSIndex = referenceResultSet.findColumn(varsToTest[i]);
        if (refRSIndex == -1) {
            throw new RuntimeException("variable '" + varsToTest[i] + "' not found in reference dataset");
        }
        ColumnDescription refColDesc = referenceResultSet.getColumnDescriptions(refRSIndex);
        double[] refData = referenceResultSet.extractColumn(refRSIndex);
        int testRSIndex = testResultSet.findColumn(varsToTest[i]);
        if (testRSIndex == -1) {
            throw new RuntimeException("variable '" + varsToTest[i] + "' not found in test dataset");
        }
        double[] testData = testResultSet.extractColumn(testRSIndex);
        DataErrorSummary tempVar = new DataErrorSummary();
        for (int j = 0; j < refData.length; j++) {
            if (type.equals(TestCaseNew.EXACT_STEADY)) {
                if (j != (refData.length - 1)) {
                    continue;
                }
            }
            tempVar.addDataValues(refData[j], testData[j], timeData[j], 0, absErrorThreshold, relErrorThreshold);
        }
        simComparisonSummary.addVariableComparisonSummary(new VariableComparisonSummary(refColDesc.getName(), tempVar.getMinRef(), tempVar.getMaxRef(), tempVar.getMaxAbsoluteError(), tempVar.getMaxRelativeError(), tempVar.getL2Norm(), tempVar.getTimeAtMaxAbsoluteError(), tempVar.getIndexAtMaxAbsoluteError(), tempVar.getTimeAtMaxRelativeError(), tempVar.getIndexAtMaxRelativeError()));
    }
    return simComparisonSummary;
}
Also used : ColumnDescription(cbit.vcell.util.ColumnDescription) ODESolverResultSetColumnDescription(cbit.vcell.math.ODESolverResultSetColumnDescription) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription)

Example 9 with ColumnDescription

use of cbit.vcell.util.ColumnDescription in project vcell by virtualcell.

the class ODESolverPlotSpecificationPanel method getSensitivityParameter.

/**
 * // Method to obtain the sensitivity parameter (if applicable). The method checks the column description names in the
 * // result set to find any column description that begins with the substring "sens" and contains the substring "wrt_".
 * // If there is, then the last portion of that column description name is the parameter name. The sensitivity parameter
 * // is also stored as a function column description in the result set (as a constant function). The value is extracted
 * // from the result set, and a new Constant is created (with the name and value of the parameter) and returned. If no
 * // column description starts with the substring "sens" or if the column for the parameter does not exist in the result
 * // set, the method returns null.
 */
private Constant getSensitivityParameter() throws ExpressionException {
    String sensParamName = "";
    ColumnDescription[] fcds = getMyDataInterface().getAllColumnDescriptions();
    // Check for any column description name that starts with the substring "sens" and contains "wrt_".
    for (int i = 0; i < fcds.length; i++) {
        if (fcds[i].getName().startsWith("sens_")) {
            int c = fcds[i].getName().indexOf("wrt_");
            sensParamName = fcds[i].getName().substring(c + 4);
            if (!sensParamName.equals(null) || !sensParamName.equals("")) {
                break;
            }
        }
    }
    double sensParamValue = 0.0;
    if (sensParamName.equals("")) {
        return null;
    }
    // If the sens param column exists in the result set, create a Constant and return it, else return null.
    try {
        sensParamValue = getMyDataInterface().extractColumn(sensParamName)[1];
    } catch (ObjectNotFoundException e) {
        // System.out.println("REUSULT SET DOES NOT HAVE SENSITIVITY ANALYSIS");
        return null;
    }
    Constant sensParam = new Constant(sensParamName, new Expression(sensParamValue));
    return sensParam;
}
Also used : Expression(cbit.vcell.parser.Expression) ColumnDescription(cbit.vcell.util.ColumnDescription) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) Constant(cbit.vcell.math.Constant) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException)

Example 10 with ColumnDescription

use of cbit.vcell.util.ColumnDescription in project vcell by virtualcell.

the class ODEDataInterfaceImpl method getFilteredColumnDescriptions.

@Override
public ColumnDescription[] getFilteredColumnDescriptions() {
    if (selectedFilters == null || simulationModelInfo == null) {
        return getOdeSolverResultSet().getColumnDescriptions();
    } else {
        ArrayList<ColumnDescription> selectedColumnDescriptions = new ArrayList<ColumnDescription>();
        for (int i = 0; i < getOdeSolverResultSet().getColumnDescriptions().length; i++) {
            DataSymbolMetadata dataSymbolMetadata = simulationModelInfo.getDataSymbolMetadataResolver().getDataSymbolMetadata(getOdeSolverResultSet().getColumnDescriptions()[i].getName());
            ModelCategoryType selectedFilterCategory = null;
            if (dataSymbolMetadata != null) {
                selectedFilterCategory = dataSymbolMetadata.filterCategory;
            }
            for (int j = 0; j < selectedFilters.length; j++) {
                if (selectedFilters[j].equals(selectedFilterCategory)) {
                    selectedColumnDescriptions.add(getOdeSolverResultSet().getColumnDescriptions()[i]);
                    break;
                }
            }
        }
        return selectedColumnDescriptions.toArray(new ColumnDescription[0]);
    }
}
Also used : FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) ColumnDescription(cbit.vcell.util.ColumnDescription) ModelCategoryType(cbit.vcell.solver.SimulationModelInfo.ModelCategoryType) ArrayList(java.util.ArrayList) DataSymbolMetadata(cbit.vcell.solver.DataSymbolMetadata)

Aggregations

ColumnDescription (cbit.vcell.util.ColumnDescription)13 FunctionColumnDescription (cbit.vcell.math.FunctionColumnDescription)9 ODESolverResultSetColumnDescription (cbit.vcell.math.ODESolverResultSetColumnDescription)4 Expression (cbit.vcell.parser.Expression)4 DataSymbolMetadata (cbit.vcell.solver.DataSymbolMetadata)3 ArrayList (java.util.ArrayList)3 Constant (cbit.vcell.math.Constant)2 ODESimData (cbit.vcell.solver.ode.ODESimData)2 ODESolverResultSet (cbit.vcell.solver.ode.ODESolverResultSet)2 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)2 Plot2D (cbit.plot.Plot2D)1 PlotData (cbit.plot.PlotData)1 SingleXPlot2D (cbit.plot.SingleXPlot2D)1 ODEDataInterface (cbit.vcell.client.data.ODEDataInterface)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 Domain (cbit.vcell.math.Variable.Domain)1 DivideByZeroException (cbit.vcell.parser.DivideByZeroException)1 ExpressionException (cbit.vcell.parser.ExpressionException)1 FunctionDomainException (cbit.vcell.parser.FunctionDomainException)1 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)1