I am exporting data from my AnyLogic model by writing/apending each run a text file from data that is being saved to the internal database. I use the below code in the Experiment's After simulation run field:
// create header
file.println("id"+","+"replicate"+","+"diagnostic_pathway_duration"+","+"total_cost_patient"+","+
"referred_gh"+","+"referred_th"+","+"tx_gh"+","+"tx_th"+","+"tx_ah"+","+"arrival_gh"+","+
"complete_gh"+","+"arrival_th"+","+"complete_th"+","+"arrival_ah"+","+"complete_ah"+","+
"pathway_concluded");
// Write data from dbase table
List<Tuple> rows = selectFrom(patient_export).list();
for (Tuple row : rows) {
file.println( row.get( patient_export.id ) + "," +
row.get( patient_export.replicate ) + "," +
row.get( patient_export.diagnostic_pathway_duration ) + "," +
row.get( patient_export.total_cost_patient ) + "," +
row.get( patient_export.referred_gh ) + "," +
row.get( patient_export.referred_th ) + "," +
row.get( patient_export.tx_gh ) + "," +
row.get( patient_export.tx_th ) + "," +
row.get( patient_export.tx_ah ) + "," +
row.get( patient_export.arrival_gh ) + "," +
row.get( patient_export.complete_gh ) + "," +
row.get( patient_export.arrival_th ) + "," +
row.get( patient_export.complete_th ) + "," +
row.get( patient_export.arrival_ah ) + "," +
row.get( patient_export.complete_ah ) + "," +
row.get( patient_export.pathway_concluded ));
}
file.close();
deleteFrom(patient_export).execute();
In the initial experiment setup field I included this code:
deleteFrom(patient_export).execute();
However, after a while no more simulation runs are being executed. The model just does not progress any more, and the CPU is not being taxed. In one instance, the experiment stopped simulating after 45 iterations, which resulted in a text file of 210 mb with approximately 1.1million rows.
I am saving the data to the internal database by triggering a function in Patient using an event. This is the code:
insertInto(patient_export)
.columns(patient_export.iteration, patient_export.replicate, patient_export.id, patient_export.diagnostic_pathway_duration,
patient_export.total_cost_patient, patient_export.referred_gh, patient_export.referred_th, patient_export.tx_gh,
patient_export.tx_th, patient_export.tx_ah, patient_export.arrival_gh, patient_export.complete_gh, patient_export.arrival_th,
patient_export.complete_th, patient_export.arrival_ah, patient_export.complete_ah, patient_export.pathway_concluded
) //database tables
.values(main.v_iteration, main.v_replicate, p_patientId, p_diagnostic_pathway_duration, p_totalCost, p_referred_GH, p_referred_TH,
p_Tx_GH, p_Tx_TH, p_Tx_AH, p_timeArrivedDxGH, p_timeCompletedDxGH, p_timeArrivedDxTH, p_timeCompletedDxTH, p_timeArrivedDxAH,
p_timeCompletedDxAH, p_diagnosticPathwayConcluded
.execute();
What am I doing wrong here? Is the internal database playing up? All help is much appreciated.

System.gc(); deleteFrom(patient_export).execute();in my experiment, my database remains large (~500 mb), although no records are listed in my database tables. Ofcourse, model execution is not logged. - mivandev