Search in sources :

Example 66 with SymbolTableEntry

use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.

the class ParameterMappingPanel method jMenuItemCopy_ActionPerformed.

/**
 * Comment
 */
private void jMenuItemCopy_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
    if (actionEvent.getSource() == getJMenuItemCopy() || actionEvent.getSource() == getJMenuItemCopyAll()) {
        try {
            // 
            // Copy Optimization Parameters (Initial Guess or Solution)
            // 
            int[] rows = null;
            if (actionEvent.getSource() == getJMenuItemCopyAll()) {
                rows = new int[getScrollPaneTable().getRowCount()];
                for (int i = 0; i < rows.length; i += 1) {
                    rows[i] = i;
                }
            } else {
                rows = getScrollPaneTable().getSelectedRows();
            }
            SimulationContext sc = getParameterEstimationTask().getModelOptimizationSpec().getSimulationContext();
            MathSymbolMapping msm = null;
            try {
                MathMapping mm = sc.createNewMathMapping();
                msm = mm.getMathSymbolMapping();
            } catch (Exception e) {
                e.printStackTrace(System.out);
                DialogUtils.showWarningDialog(this, "current math not valid, some paste operations will be limited\n\nreason: " + e.getMessage());
            }
            boolean bInitialGuess = (getScrollPaneTable().getSelectedColumn() == ParameterMappingTableModel.COLUMN_CURRENTVALUE);
            ParameterMappingSpec[] parameterMappingSpecs = new ParameterMappingSpec[rows.length];
            java.util.Vector<SymbolTableEntry> primarySymbolTableEntriesV = new java.util.Vector<SymbolTableEntry>();
            java.util.Vector<SymbolTableEntry> alternateSymbolTableEntriesV = new java.util.Vector<SymbolTableEntry>();
            java.util.Vector<Expression> resolvedValuesV = new java.util.Vector<Expression>();
            // 
            // Create formatted string for text/spreadsheet pasting.
            // 
            StringBuffer sb = new StringBuffer();
            sb.append("\"Parameters for (Optimization Task)" + getParameterEstimationTask().getName() + " -> " + "(BioModel)" + getParameterEstimationTask().getModelOptimizationSpec().getSimulationContext().getBioModel().getName() + " -> " + "(App)" + getParameterEstimationTask().getModelOptimizationSpec().getSimulationContext().getName() + "\"\n");
            sb.append("\"Parameter Name\"\t\"" + (bInitialGuess ? "Initial Guess" : "Solution") + "\"\n");
            for (int i = 0; i < rows.length; i += 1) {
                ParameterMappingSpec pms = parameterMappingTableModel.getValueAt(rows[i]);
                parameterMappingSpecs[i] = pms;
                primarySymbolTableEntriesV.add(pms.getModelParameter());
                if (msm != null) {
                    alternateSymbolTableEntriesV.add(msm.getVariable(pms.getModelParameter()));
                } else {
                    alternateSymbolTableEntriesV.add(null);
                }
                Double resolvedValue = null;
                if (!bInitialGuess) {
                    resolvedValue = getParameterEstimationTask().getCurrentSolution(pms);
                }
                if (resolvedValue == null) {
                    resolvedValue = new Double(pms.getCurrent());
                }
                resolvedValuesV.add(new Expression(resolvedValue.doubleValue()));
                sb.append("\"" + parameterMappingSpecs[i].getModelParameter().getName() + "\"\t" + resolvedValue + "\n");
            }
            // 
            // Send to clipboard
            // 
            VCellTransferable.ResolvedValuesSelection rvs = new VCellTransferable.ResolvedValuesSelection((SymbolTableEntry[]) BeanUtils.getArray(primarySymbolTableEntriesV, SymbolTableEntry.class), (SymbolTableEntry[]) BeanUtils.getArray(alternateSymbolTableEntriesV, SymbolTableEntry.class), (Expression[]) BeanUtils.getArray(resolvedValuesV, Expression.class), sb.toString());
            VCellTransferable.sendToClipboard(rvs);
        } catch (Throwable e) {
            PopupGenerator.showErrorDialog(this, "ParameterMappingPanel copy failed.  " + e.getMessage(), e);
        }
    }
}
Also used : VCellTransferable(cbit.vcell.desktop.VCellTransferable) SimulationContext(cbit.vcell.mapping.SimulationContext) MathSymbolMapping(cbit.vcell.mapping.MathSymbolMapping) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Expression(cbit.vcell.parser.Expression) ParameterMappingSpec(cbit.vcell.modelopt.ParameterMappingSpec) MathMapping(cbit.vcell.mapping.MathMapping)

Example 67 with SymbolTableEntry

use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.

the class SymbolTableEntryTableCellRenderer method getTableCellRendererComponent.

public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    if (value == null) {
        setText("unmapped");
        return this;
    }
    SymbolTableEntry ste = (SymbolTableEntry) value;
    if (ste instanceof Model.ReservedSymbol) {
        setText(ste.getName());
    } else if (ste instanceof SpeciesContext) {
        setText("[" + ste.getName() + "]");
    } else if (ste instanceof KineticsParameter) {
        setText(ste.getNameScope().getName() + ":" + ste.getName());
    } else if (ste instanceof ModelParameter) {
        setText(ste.getName());
    } else if (ste instanceof ReservedVariable) {
        setText(ste.getName());
    } else {
        setText(ste.getNameScope().getAbsoluteScopePrefix() + ste.getName());
    }
    // setToolTipText("Kinetic parameter \""+ste.getName()+"\" in reaction "+);
    return this;
}
Also used : ModelParameter(cbit.vcell.model.Model.ModelParameter) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) ReservedVariable(cbit.vcell.math.ReservedVariable) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) SpeciesContext(cbit.vcell.model.SpeciesContext)

Example 68 with SymbolTableEntry

use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.

the class SimulationContext method getLocalEntry.

/**
 * Insert the method's description here.
 * Creation date: (12/8/2003 10:17:30 AM)
 * @return SymbolTableEntry
 * @param identifier java.lang.String
 */
public SymbolTableEntry getLocalEntry(java.lang.String identifier) {
    // try field function(s) first
    if (identifier.equals(MathFunctionDefinitions.fieldFunctionDefinition.getName())) {
        return MathFunctionDefinitions.fieldFunctionDefinition;
    }
    SymbolTableEntry ste = getSimulationContextParameter(identifier);
    if (ste != null) {
        return ste;
    }
    for (SpatialObject spatialObject : spatialObjects) {
        SpatialQuantity appQuantity = spatialObject.getSpatialQuantity(identifier);
        if (appQuantity != null) {
            return appQuantity;
        }
    }
    // if dataContext parameter exists, then return it
    ste = getDataContext().getDataSymbol(identifier);
    if (ste != null) {
        return ste;
    }
    // if not found in simulationContext, try model level
    ste = getModel().getLocalEntry(identifier);
    if (ste != null) {
        return ste;
    }
    return null;
}
Also used : SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) SpatialQuantity(cbit.vcell.mapping.spatial.SpatialObject.SpatialQuantity) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject)

Example 69 with SymbolTableEntry

use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.

the class SpeciesContextSpec method getLocalEntry.

/**
 * Insert the method's description here.
 * Creation date: (12/8/2003 11:46:37 AM)
 * @return SymbolTableEntry
 * @param identifier java.lang.String
 */
public SymbolTableEntry getLocalEntry(java.lang.String identifier) {
    SymbolTableEntry ste = null;
    ste = getParameterFromName(identifier);
    if (ste != null) {
        return ste;
    }
    ste = getProxyParameter(identifier);
    if (ste != null) {
        return ste;
    }
    return null;
}
Also used : SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry)

Example 70 with SymbolTableEntry

use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.

the class PotentialMapping method getOdeRHS.

/**
 * Insert the method's description here.
 * Creation date: (4/24/2002 10:45:35 AM)
 * @return cbit.vcell.parser.Expression
 * @param capacitiveDevice cbit.vcell.mapping.potential.ElectricalDevice
 */
public Expression getOdeRHS(MembraneElectricalDevice capacitiveDevice, AbstractMathMapping mathMapping) throws ExpressionException, MappingException {
    NameScope nameScope = mathMapping.getNameScope();
    Expression transMembraneCurrent = capacitiveDevice.getParameterFromRole(ElectricalDevice.ROLE_TransmembraneCurrent).getExpression().renameBoundSymbols(nameScope);
    Expression totalCapacitance = new Expression(capacitiveDevice.getCapacitanceParameter(), nameScope);
    Expression totalCurrent = new Expression(capacitiveDevice.getTotalCurrentSymbol(), nameScope);
    ModelUnitSystem modelUnitSystem = fieldMathMapping.getSimulationContext().getModel().getUnitSystem();
    VCUnitDefinition potentialUnit = modelUnitSystem.getVoltageUnit();
    VCUnitDefinition timeUnit = modelUnitSystem.getTimeUnit();
    SymbolTableEntry capacitanceParameter = capacitiveDevice.getCapacitanceParameter();
    VCUnitDefinition unitFactor = potentialUnit.divideBy(timeUnit).multiplyBy(capacitanceParameter.getUnitDefinition()).divideBy(capacitiveDevice.getTotalCurrentSymbol().getUnitDefinition());
    Expression unitFactorExp = fieldMathMapping.getUnitFactor(unitFactor);
    Expression exp = Expression.mult(Expression.div(unitFactorExp, totalCapacitance), Expression.add(totalCurrent, Expression.negate(transMembraneCurrent)));
    // exp.bindExpression(mathMapping);
    return exp;
}
Also used : VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) NameScope(cbit.vcell.parser.NameScope) Expression(cbit.vcell.parser.Expression) ModelUnitSystem(cbit.vcell.model.ModelUnitSystem)

Aggregations

SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)115 Expression (cbit.vcell.parser.Expression)50 ExpressionException (cbit.vcell.parser.ExpressionException)20 Vector (java.util.Vector)20 ArrayList (java.util.ArrayList)19 SpeciesContext (cbit.vcell.model.SpeciesContext)18 ModelParameter (cbit.vcell.model.Model.ModelParameter)14 PropertyVetoException (java.beans.PropertyVetoException)14 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)13 Model (cbit.vcell.model.Model)12 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)11 HashMap (java.util.HashMap)11 SimulationContext (cbit.vcell.mapping.SimulationContext)10 Variable (cbit.vcell.math.Variable)10 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)9 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)9 Parameter (cbit.vcell.model.Parameter)9 SingleXPlot2D (cbit.plot.SingleXPlot2D)8 MathException (cbit.vcell.math.MathException)8 ReservedVariable (cbit.vcell.math.ReservedVariable)8