From 08935a460fd78a404685f0132b58d3babe193909 Mon Sep 17 00:00:00 2001 From: Dan Vasilescu Date: Thu, 30 Jan 2025 14:00:40 -0500 Subject: [PATCH] WIP - new LangevinPostProcessor located in core, here all post processing happens --- .../cbit/vcell/client/ClientSimManager.java | 42 ++---- .../vcell/simdata/LangevinPostProcessor.java | 142 ++++++++++++++++++ 2 files changed, 152 insertions(+), 32 deletions(-) create mode 100644 vcell-core/src/main/java/cbit/vcell/simdata/LangevinPostProcessor.java diff --git a/vcell-client/src/main/java/cbit/vcell/client/ClientSimManager.java b/vcell-client/src/main/java/cbit/vcell/client/ClientSimManager.java index 796b3f1567..b704688999 100644 --- a/vcell-client/src/main/java/cbit/vcell/client/ClientSimManager.java +++ b/vcell-client/src/main/java/cbit/vcell/client/ClientSimManager.java @@ -25,6 +25,7 @@ import cbit.vcell.client.task.AsynchClientTaskFunction; import cbit.vcell.client.task.ClientTaskDispatcher; import cbit.vcell.export.server.ExportServiceImpl; +import cbit.vcell.export.server.ExportSpecs; import cbit.vcell.field.FieldDataIdentifierSpec; import cbit.vcell.mapping.SimulationContext; import cbit.vcell.mapping.SimulationContext.NetworkGenerationRequirements; @@ -203,45 +204,22 @@ public void showSimulationResults(OutputContext outputContext, Simulation[] simu */ public void postProcessLangevinResults(Simulation sim) { - final String FAILURE_KEY = "FAILURE_KEY"; - final String SIMULATION_KEY = "SIMULATION_KEY"; + SimulationOwner simOwner = getSimWorkspace().getSimulationOwner(); + Hashtable hashTable = new Hashtable(); - hashTable.put(FAILURE_KEY, false); - hashTable.put(SIMULATION_KEY, sim); + hashTable.put(LangevinPostProcessor.FAILURE_KEY, false); + hashTable.put(LangevinPostProcessor.SIMULATION_KEY, sim); + hashTable.put(LangevinPostProcessor.SIMULATION_OWNER, simOwner); ArrayList taskList = new ArrayList(); - AsynchClientTask retrieveLangevinResultsTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) { + AsynchClientTask postProcessLangevinResultsTask = new AsynchClientTask("PostProcessLangevinResultsTask", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) { public void run(Hashtable hashTable) throws Exception { - boolean failure = (boolean) hashTable.get(FAILURE_KEY); - SolverTaskDescription std = sim.getSolverTaskDescription(); - int numTrials = std.getNumTrials(); - System.out.println(sim.getName() + ", NumTrials = " + numTrials); -// LangevinSimulationOptions lso = std.getLangevinSimulationOptions(); - final VCSimulationIdentifier vcSimulationIdentifier = sim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(); - SimulationOwner simOwner = getSimWorkspace().getSimulationOwner(); - Simulation allSims[] = simOwner.getSimulations(); - for (Simulation simCandidate : allSims) { - if (simCandidate.getName().startsWith(sim.getName())) { - System.out.println(" --- " + simCandidate.getName() + ", " + simCandidate.getJobCount()); - } - } + LangevinPostProcessor lpp = new LangevinPostProcessor(); + lpp.postProcessLangevinResults(hashTable); } }; - AsynchClientTask calculateLangevinAveragesTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) { - public void run(Hashtable hashTable) throws Exception { - boolean failure = (boolean)hashTable.get(FAILURE_KEY); - } - }; - AsynchClientTask calculateLangevinAdvancedStatisticsTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) { - public void run(Hashtable hashTable) throws Exception { - boolean failure = (boolean)hashTable.get(FAILURE_KEY); - - } - }; - taskList.add(retrieveLangevinResultsTask); - taskList.add(calculateLangevinAveragesTask); - taskList.add(calculateLangevinAdvancedStatisticsTask); + taskList.add(postProcessLangevinResultsTask); AsynchClientTask[] taskArray = new AsynchClientTask[taskList.size()]; taskList.toArray(taskArray); ClientTaskDispatcher.dispatch(getDocumentWindowManager().getComponent(), hashTable, taskArray, false, true, null); diff --git a/vcell-core/src/main/java/cbit/vcell/simdata/LangevinPostProcessor.java b/vcell-core/src/main/java/cbit/vcell/simdata/LangevinPostProcessor.java new file mode 100644 index 0000000000..404f859fcc --- /dev/null +++ b/vcell-core/src/main/java/cbit/vcell/simdata/LangevinPostProcessor.java @@ -0,0 +1,142 @@ +package cbit.vcell.simdata; + +import cbit.vcell.export.server.ExportSpecs; +import cbit.vcell.solver.*; +import cbit.vcell.solver.ode.ODESimData; + +import java.util.ArrayList; +import java.util.Hashtable; + +public class LangevinPostProcessor { + + public static final String FAILURE_KEY = "FAILURE_KEY"; + public static final String SIMULATION_KEY = "SIMULATION_KEY"; + public static final String SIMULATION_OWNER = "SIMULATION_OWNER"; + + boolean failure; + Simulation sim; + SimulationOwner simOwner; + + public void postProcessLangevinResults(Hashtable hashTable) { + + failure = (boolean) hashTable.get(FAILURE_KEY); + sim = (Simulation)hashTable.get(SIMULATION_KEY); + simOwner = (SimulationOwner)hashTable.get(SIMULATION_OWNER);; + + if(sim.getVersion() == null) { + throw new RuntimeException("Missing Version."); + } + if(sim.getSimulationInfo() == null) { + throw new RuntimeException("Missing Simulation Info."); + } + + retrieveLangevinResultsTask(); + calculateLangevinAveragesTask(); + calculateLangevinAdvancedStatisticsTask(); + } + + private void retrieveLangevinResultsTask() { + SolverTaskDescription std = sim.getSolverTaskDescription(); + int numTrials = std.getNumTrials(); + VCSimulationIdentifier vcSimulationIdentifier = sim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(); + MathOverrides mathOverrides = sim.getMathOverrides(); + int sizeOverrides = mathOverrides.getSize(); + int scanCount = mathOverrides.getScanCount(); + + System.out.println(" --- " + sim.getName() + ", numTrials = " + numTrials); + System.out.println(" --- " + sim.getName() + ", jobCount" + sim.getJobCount()); + System.out.println(" --- " + sim.getName() + ", sizeOverrides = " + sizeOverrides); + System.out.println(" --- " + sim.getName() + ", scanCount = " + scanCount); + + SimulationInfo simInfo = sim.getSimulationInfo(); + VCSimulationIdentifier asi = simInfo.getAuthoritativeVCSimulationIdentifier(); + VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(asi, 0); + +// ODEDataManager dm = (ODEDataManager)getDocumentWindowManager().getRequestManager().getDataManager(null, vcSimulationDataIdentifier, false); +// ODESimData osd = (ODESimData)dm.getODESolverResultSet(); + + + System.out.println(" ------------------------------------"); + + } + private void calculateLangevinAveragesTask() { + + } + private void calculateLangevinAdvancedStatisticsTask() { + + } + +// public void postProcessLangevinResults(Simulation sim) { +// +// final String FAILURE_KEY = "FAILURE_KEY"; +// final String SIMULATION_KEY = "SIMULATION_KEY"; +// Hashtable hashTable = new Hashtable(); +// hashTable.put(FAILURE_KEY, false); +// hashTable.put(SIMULATION_KEY, sim); +// +// ArrayList taskList = new ArrayList(); +// AsynchClientTask retrieveLangevinResultsTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) { +// public void run(Hashtable hashTable) throws Exception { +// boolean failure = (boolean) hashTable.get(FAILURE_KEY); +// SolverTaskDescription std = sim.getSolverTaskDescription(); +// int numTrials = std.getNumTrials(); +// System.out.println(sim.getName() + ", numTrials = " + numTrials); +//// LangevinSimulationOptions lso = std.getLangevinSimulationOptions(); +// final VCSimulationIdentifier vcSimulationIdentifier = sim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(); +// SimulationOwner simOwner = getSimWorkspace().getSimulationOwner(); +// Simulation allSims[] = simOwner.getSimulations(); +// for (Simulation simCandidate : allSims) { +// if (simCandidate.getName().startsWith(sim.getName())) { +// System.out.println(" --- " + simCandidate.getName() + ", jobCount" + simCandidate.getJobCount()); +// MathOverrides mathOverrides = simCandidate.getMathOverrides(); +// int sizeOverrides = mathOverrides.getSize(); +// int scanCount = mathOverrides.getScanCount(); +// System.out.println(" --- " + sim.getName() + ", sizeOverrides = " + sizeOverrides); +// System.out.println(" --- " + sim.getName() + ", scanCount = " + scanCount); +// +// ExportSpecs.ExportParamScanInfo es = ExportSpecs.getParamScanInfo(simCandidate,0); +// ExportSpecs.ExportParamScanInfo es1 = ExportSpecs.getParamScanInfo(simCandidate,1); +// ExportSpecs.ExportParamScanInfo es2 = ExportSpecs.getParamScanInfo(simCandidate,2); +// +// if(sim.getVersion() == null) { +// throw new RuntimeException("Missing Version."); +// } +// SimulationInfo simInfo = sim.getSimulationInfo(); +// if(simInfo == null) { +// throw new RuntimeException("Missing Simulation Info."); +// } +// +// VCSimulationIdentifier asi = simInfo.getAuthoritativeVCSimulationIdentifier(); +// VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(asi, 0); +// +// ODEDataManager dm = (ODEDataManager)getDocumentWindowManager().getRequestManager().getDataManager(outputContext, vcSimulationDataIdentifier, false); +// ODESimData osd = (ODESimData)dm.getODESolverResultSet(); +// +// +// System.out.println(" ------------------------------------"); +// } +// } +// } +// }; +// AsynchClientTask calculateLangevinAveragesTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) { +// public void run(Hashtable hashTable) throws Exception { +// boolean failure = (boolean)hashTable.get(FAILURE_KEY); +// +// } +// }; +// AsynchClientTask calculateLangevinAdvancedStatisticsTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) { +// public void run(Hashtable hashTable) throws Exception { +// boolean failure = (boolean)hashTable.get(FAILURE_KEY); +// +// } +// }; +// taskList.add(retrieveLangevinResultsTask); +// taskList.add(calculateLangevinAveragesTask); +// taskList.add(calculateLangevinAdvancedStatisticsTask); +// AsynchClientTask[] taskArray = new AsynchClientTask[taskList.size()]; +// taskList.toArray(taskArray); +// ClientTaskDispatcher.dispatch(getDocumentWindowManager().getComponent(), hashTable, taskArray, false, true, null); +// +// } + +}