Skip to content

Commit

Permalink
WIP - deep initialize / copy a RowColumnResultSet
Browse files Browse the repository at this point in the history
  • Loading branch information
danv61 committed Feb 7, 2025
1 parent 5bed492 commit 5169924
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
22 changes: 22 additions & 0 deletions vcell-core/src/main/java/cbit/vcell/math/RowColumnResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ public RowColumnResultSet(RowColumnResultSet copyThisRowColumnResultSet){
this.fieldValues = new ArrayList<>(copyThisRowColumnResultSet.fieldValues);
}

public enum DuplicateMode {
CopyValues,
ZeroInitialize
}
public static RowColumnResultSet deepCopy(RowColumnResultSet original, DuplicateMode mode) {
RowColumnResultSet copy = new RowColumnResultSet();
copy.fieldDataColumnDescriptions = new Vector<>(original.fieldDataColumnDescriptions);
copy.fieldFunctionColumnDescriptions = new Vector<>(original.fieldFunctionColumnDescriptions);
copy.fieldValues = new ArrayList<>();
for (double[] originalRow : original.fieldValues) {
double[] copyRow = new double[originalRow.length];
if(mode == DuplicateMode.CopyValues) {
System.arraycopy(originalRow, 0, copyRow, 0, originalRow.length);
}
copy.fieldValues.add(copyRow);
}



return copy;
}

/**
* SimpleODEData constructor comment.
* JMW : THIS NEEDS TO BE FIXED...THIS CONSTRUCTOR SHOULD NOT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cbit.vcell.simdata;

import cbit.vcell.mapping.SimulationContext;
import cbit.vcell.math.RowColumnResultSet;
import cbit.vcell.solver.*;
import cbit.vcell.solver.ode.ODESimData;
import cbit.vcell.solver.ode.ODESolverResultSet;
Expand All @@ -9,6 +10,8 @@
import org.vcell.util.TokenMangler;
import org.vcell.util.document.SimulationVersion;

import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
Expand All @@ -29,10 +32,10 @@ public class LangevinPostProcessor {
Map<Integer, ODEDataManager> odeDataManagerMap;

// the results
ODESolverResultSet averagesResultSet;
ODESolverResultSet stdResultSet;
ODESolverResultSet minResultSet;
ODESolverResultSet maxResultSet;
RowColumnResultSet averagesResultSet;
RowColumnResultSet stdResultSet;
RowColumnResultSet minResultSet;
RowColumnResultSet maxResultSet;

public void postProcessLangevinResults(Hashtable<String, Object> aHashTable) throws DataAccessException {

Expand All @@ -56,20 +59,19 @@ public void postProcessLangevinResults(Hashtable<String, Object> aHashTable) thr
SimulationVersion simVersion = simInfo.getSimulationVersion();

ODEDataManager tempODEDataManager = odeDataManagerMap.get(0);
// ODEDataManager tempODEDataManager1 = odeDataManagerMap.get(1);
ODESimData tempODESimData = (ODESimData)tempODEDataManager.getODESolverResultSet();
String format = tempODESimData.getFormatID();
String mathName = tempODESimData.getMathName(); // should be different instances?

// sanity check: shouldn't be, that only works for non-spatial stochastic where things are done differently
System.out.println("isGibsonMultiTrial: " + tempODEDataManager.getODESolverResultSet().isMultiTrialData());

averagesResultSet = new ODESolverResultSet(tempODEDataManager.getODESolverResultSet());
stdResultSet = new ODESolverResultSet(tempODEDataManager.getODESolverResultSet());
minResultSet = new ODESolverResultSet(tempODEDataManager.getODESolverResultSet());
maxResultSet = new ODESolverResultSet(tempODEDataManager.getODESolverResultSet());
averagesResultSet = RowColumnResultSet.deepCopy(tempODEDataManager.getODESolverResultSet(), RowColumnResultSet.DuplicateMode.ZeroInitialize);
stdResultSet = RowColumnResultSet.deepCopy(tempODEDataManager.getODESolverResultSet(), RowColumnResultSet.DuplicateMode.ZeroInitialize);
minResultSet = RowColumnResultSet.deepCopy(tempODEDataManager.getODESolverResultSet(), RowColumnResultSet.DuplicateMode.CopyValues);
maxResultSet = RowColumnResultSet.deepCopy(tempODEDataManager.getODESolverResultSet(), RowColumnResultSet.DuplicateMode.CopyValues);

initializeResultSetValues(averagesResultSet);
initializeResultSetValues(stdResultSet);
// we leave the min and max initialized with whatever the first trial has and adjust as we go through the other trials
if(failure) {
return;
Expand Down Expand Up @@ -98,7 +100,7 @@ private void calculateLangevinPrimaryStatistics() throws DataAccessException {
if (name.equals("t")) {
continue;
}
averageRowData[i] = sourceRowData[i] / numTrials;
averageRowData[i] += sourceRowData[i] / numTrials;
if (minRowData[i] > sourceRowData[i]) {
minRowData[i] = sourceRowData[i];
}
Expand Down Expand Up @@ -147,29 +149,12 @@ private void calculateLangevinPrimaryStatistics() throws DataAccessException {
System.out.println(" ------------------------------------");
}

private void initializeResultSetValues(ODESolverResultSet osrs) {
int columnDescriptionCount = osrs.getColumnDescriptionsCount();
int rowCount = osrs.getRowCount();
List<double[]> rows = osrs.getRows();
for(int row = 0; row < rowCount; row++) {
double[] rowData = osrs.getRow(row);
for(int i = 0; i < rowData.length; i++) {
ColumnDescription cd = osrs.getColumnDescriptions(i);
String name = cd.getName();
if(name.equals("t")) {
continue;
}
rowData[i] = 0;
}
}
private void calculateLangevinAdvancedStatistics() {

System.out.println("post process langevin");
}


private void calculateLangevinAdvancedStatistics() {

}

// private static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy_MM_dd_HHmmss");
// private static File createDirFile(SimulationContext simulationContext){
Expand Down

0 comments on commit 5169924

Please sign in to comment.