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);
}
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations