diff --git a/Project.toml b/Project.toml
index 6e55b3f..d207a25 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,7 +1,7 @@
name = "SimulationService"
uuid = "e66378d9-a322-4933-8764-0ce0bcab4993"
authors = ["Five Grant <5@fivegrant.com>"]
-version = "0.13.0"
+version = "0.14.0"
[deps]
AMQPClient = "79c8b4cd-a41a-55fa-907c-fab5288e1383"
diff --git a/examples/BIOMD0000000955_askenet.json b/examples/calibrate_example1/BIOMD0000000955_askenet.json
similarity index 100%
rename from examples/BIOMD0000000955_askenet.json
rename to examples/calibrate_example1/BIOMD0000000955_askenet.json
diff --git a/examples/dataset.csv b/examples/calibrate_example1/dataset.csv
similarity index 100%
rename from examples/dataset.csv
rename to examples/calibrate_example1/dataset.csv
diff --git a/examples/request-calibrate-no-integration.json b/examples/calibrate_example1/request-calibrate-no-integration.json
similarity index 100%
rename from examples/request-calibrate-no-integration.json
rename to examples/calibrate_example1/request-calibrate-no-integration.json
diff --git a/examples/calibrate_example2/SIRModelConfiguartion.json b/examples/calibrate_example2/SIRModelConfiguartion.json
new file mode 100644
index 0000000..f37f678
--- /dev/null
+++ b/examples/calibrate_example2/SIRModelConfiguartion.json
@@ -0,0 +1,642 @@
+{
+ "id": "55ca595f-940d-458c-9c73-7c315a10b559",
+ "name": "Default config",
+ "description": "Default config",
+ "timestamp": "2023-07-13T20:18:12",
+ "model_id": "0984a5a9-6438-4041-aa11-2f9ea8fc9d4a",
+ "configuration": {
+ "id": "0984a5a9-6438-4041-aa11-2f9ea8fc9d4a",
+ "name": "SIRs",
+ "description": "SIR model",
+ "model_version": "0.1",
+ "schema": "https://raw.githubusercontent.com/DARPA-ASKEM/Model-Representations/petrinet_v0.5/petrinet/petrinet_schema.json",
+ "schema_name": "petrinet",
+ "model": {
+ "states": [
+ {
+ "id": "S",
+ "name": "Susceptible",
+ "description": "Number of individuals that are 'susceptible' to a disease infection",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000514"
+ }
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "I",
+ "name": "Infected",
+ "description": "Number of individuals that are 'infected' by a disease",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000511"
+ }
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ },
+ {
+ "id": "R",
+ "name": "Recovered",
+ "description": "Number of individuals that have 'recovered' from a disease infection",
+ "grounding": {
+ "identifiers": {
+ "ido": "0000592"
+ }
+ },
+ "units": {
+ "expression": "person",
+ "expression_mathml": "person"
+ }
+ }
+ ],
+ "transitions": [
+ {
+ "id": "inf",
+ "input": [
+ "I",
+ "S"
+ ],
+ "output": [
+ "I",
+ "I"
+ ],
+ "properties": {
+ "name": "Infection",
+ "description": "Infective process between individuals"
+ }
+ },
+ {
+ "id": "rec",
+ "input": [
+ "I"
+ ],
+ "output": [
+ "R"
+ ],
+ "properties": {
+ "name": "Recovery",
+ "description": "Recovery process of a infected individual"
+ }
+ }
+ ]
+ },
+ "semantics": {
+ "ode": {
+ "rates": [
+ {
+ "target": "inf",
+ "expression": "S*I*beta",
+ "expression_mathml": "SIbeta"
+ },
+ {
+ "target": "rec",
+ "expression": "I*gamma",
+ "expression_mathml": "Igamma"
+ }
+ ],
+ "initials": [
+ {
+ "target": "S",
+ "expression": "S0",
+ "expression_mathml": "S0"
+ },
+ {
+ "target": "I",
+ "expression": "I0",
+ "expression_mathml": "I0"
+ },
+ {
+ "target": "R",
+ "expression": "R0",
+ "expression_mathml": "R0"
+ }
+ ],
+ "parameters": [
+ {
+ "id": "beta",
+ "description": "infection rate",
+ "value": 2.7e-7,
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 2.6e-7,
+ "maximum": 2.8e-7
+ }
+ }
+ },
+ {
+ "id": "gamma",
+ "description": "recovery rate",
+ "value": 0.14,
+ "grounding": {
+ "identifiers": {
+ "askemo": "0000013"
+ }
+ },
+ "distribution": {
+ "type": "Uniform1",
+ "parameters": {
+ "minimum": 0.1,
+ "maximum": 0.18
+ }
+ }
+ },
+ {
+ "id": "S0",
+ "description": "Total susceptible population at timestep 0",
+ "value": 1000
+ },
+ {
+ "id": "I0",
+ "description": "Total infected population at timestep 0",
+ "value": 1
+ },
+ {
+ "id": "R0",
+ "description": "Total recovered population at timestep 0",
+ "value": 0
+ }
+ ],
+ "observables": [
+ {
+ "id": "noninf",
+ "name": "Non-infectious",
+ "states": [
+ "S",
+ "R"
+ ],
+ "expression": "S+R",
+ "expression_mathml": "SR"
+ }
+ ],
+ "time": {
+ "id": "t",
+ "units": {
+ "expression": "day",
+ "expression_mathml": "day"
+ }
+ }
+ }
+ },
+ "metadata": {
+ "attributes": [
+ {
+ "type": "anchored_extraction",
+ "payload": {
+ "id": {
+ "id": "R:190348269"
+ },
+ "names": [
+ {
+ "id": {
+ "id": "T:-1709799622"
+ },
+ "name": "Bucky",
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 738,
+ "char_end": 743,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.974474"
+ }
+ }
+ ],
+ "descriptions": [
+ {
+ "id": {
+ "id": "T:-486841659"
+ },
+ "source": "time",
+ "grounding": [
+ {
+ "grounding_text": "time since time scale zero",
+ "grounding_id": "apollosv:00000272",
+ "source": [],
+ "score": 0.8945620059967041,
+ "provenance": {
+ "method": "SKEMA-TR-Embedding",
+ "timestamp": "2023-06-15T22:59:11.974644"
+ }
+ }
+ ],
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 732,
+ "char_end": 736,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.974474"
+ }
+ }
+ ],
+ "value_specs": [],
+ "groundings": []
+ }
+ },
+ {
+ "type": "anchored_extraction",
+ "payload": {
+ "id": {
+ "id": "R:159895595"
+ },
+ "names": [
+ {
+ "id": {
+ "id": "T:2131207786"
+ },
+ "name": "SEIR",
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 56,
+ "char_end": 60,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.974780"
+ }
+ }
+ ],
+ "descriptions": [
+ {
+ "id": {
+ "id": "T:-1520869470"
+ },
+ "source": "spatially distributed",
+ "grounding": [],
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 34,
+ "char_end": 55,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.974780"
+ }
+ }
+ ],
+ "value_specs": [],
+ "groundings": []
+ }
+ },
+ {
+ "type": "anchored_extraction",
+ "payload": {
+ "id": {
+ "id": "E:-337831219"
+ },
+ "names": [
+ {
+ "id": {
+ "id": "T:1326919589"
+ },
+ "name": "S",
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 562,
+ "char_end": 563,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.974931"
+ }
+ }
+ ],
+ "descriptions": [
+ {
+ "id": {
+ "id": "T:1687413640"
+ },
+ "source": "fraction of the population",
+ "grounding": [
+ {
+ "grounding_text": "count of simulated population",
+ "grounding_id": "apollosv:00000022",
+ "source": [],
+ "score": 0.8330355286598206,
+ "provenance": {
+ "method": "SKEMA-TR-Embedding",
+ "timestamp": "2023-06-15T22:59:11.975009"
+ }
+ }
+ ],
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 570,
+ "char_end": 596,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.974931"
+ }
+ }
+ ],
+ "value_specs": [],
+ "groundings": [
+ {
+ "grounding_text": "Meruvax I",
+ "grounding_id": "vo:0003109",
+ "source": [],
+ "score": 0.7847759127616882,
+ "provenance": {
+ "method": "SKEMA-TR-Embedding",
+ "timestamp": "2023-06-15T22:59:11.974960"
+ }
+ }
+ ]
+ }
+ },
+ {
+ "type": "anchored_extraction",
+ "payload": {
+ "id": {
+ "id": "E:-1921441554"
+ },
+ "names": [
+ {
+ "id": {
+ "id": "T:-24678027"
+ },
+ "name": "asym frac",
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 142,
+ "char_end": 151,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.975127"
+ }
+ },
+ {
+ "id": {
+ "id": "v10"
+ },
+ "name": "α",
+ "provenance": {
+ "method": "MIT extractor V1.0 - text, dataset, formula annotation (chunwei@mit.edu)",
+ "timestamp": "2023-06-15T22:59:13.177022"
+ }
+ }
+ ],
+ "descriptions": [
+ {
+ "id": {
+ "id": "T:1244663286"
+ },
+ "source": "percentage of infections",
+ "grounding": [
+ {
+ "grounding_text": "percentage of cases",
+ "grounding_id": "cemo:percentage_of_cases",
+ "source": [],
+ "score": 0.8812347650527954,
+ "provenance": {
+ "method": "SKEMA-TR-Embedding",
+ "timestamp": "2023-06-15T22:59:11.975201"
+ }
+ }
+ ],
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 94,
+ "char_end": 118,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.975127"
+ }
+ },
+ {
+ "id": {
+ "id": "v10"
+ },
+ "source": " Rate of infections that are asymptomatic",
+ "provenance": {
+ "method": "MIT extractor V1.0 - text, dataset, formula annotation (chunwei@mit.edu)",
+ "timestamp": "2023-06-15T22:59:13.177022"
+ }
+ }
+ ],
+ "value_specs": [],
+ "groundings": [
+ {
+ "grounding_text": "Van",
+ "grounding_id": "geonames:298117",
+ "source": [],
+ "score": 1,
+ "provenance": {
+ "method": "MIT extractor V1.0 - text, dataset, formula annotation (chunwei@mit.edu)",
+ "timestamp": "2023-06-15T22:59:13.177022"
+ }
+ },
+ {
+ "grounding_text": "Sanaa",
+ "grounding_id": "geonames:71137",
+ "source": [],
+ "score": 1,
+ "provenance": {
+ "method": "MIT extractor V1.0 - text, dataset, formula annotation (chunwei@mit.edu)",
+ "timestamp": "2023-06-15T22:59:13.177022"
+ }
+ }
+ ]
+ }
+ },
+ {
+ "type": "anchored_extraction",
+ "payload": {
+ "id": {
+ "id": "E:392549189"
+ },
+ "names": [
+ {
+ "id": {
+ "id": "T:-24678027"
+ },
+ "name": "asym frac",
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 142,
+ "char_end": 151,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.975270"
+ }
+ },
+ {
+ "id": {
+ "id": "v18"
+ },
+ "name": "asym_frac",
+ "provenance": {
+ "method": "MIT extractor V1.0 - text, dataset, formula annotation (chunwei@mit.edu)",
+ "timestamp": "2023-06-15T22:59:13.177022"
+ }
+ }
+ ],
+ "descriptions": [
+ {
+ "id": {
+ "id": "T:1244663286"
+ },
+ "source": "percentage of infections",
+ "grounding": [
+ {
+ "grounding_text": "percentage of cases",
+ "grounding_id": "cemo:percentage_of_cases",
+ "source": [],
+ "score": 0.8812347650527954,
+ "provenance": {
+ "method": "SKEMA-TR-Embedding",
+ "timestamp": "2023-06-15T22:59:11.975340"
+ }
+ }
+ ],
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 94,
+ "char_end": 118,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.975270"
+ }
+ },
+ {
+ "id": {
+ "id": "v18"
+ },
+ "source": " Fraction of infections that are asymptomatic",
+ "provenance": {
+ "method": "MIT extractor V1.0 - text, dataset, formula annotation (chunwei@mit.edu)",
+ "timestamp": "2023-06-15T22:59:13.177022"
+ }
+ }
+ ],
+ "value_specs": [],
+ "groundings": []
+ }
+ },
+ {
+ "type": "anchored_extraction",
+ "payload": {
+ "id": {
+ "id": "E:-1790112729"
+ },
+ "names": [
+ {
+ "id": {
+ "id": "T:-24678027"
+ },
+ "name": "asym frac",
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 142,
+ "char_end": 151,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.975409"
+ }
+ }
+ ],
+ "descriptions": [
+ {
+ "id": {
+ "id": "T:1244663286"
+ },
+ "source": "percentage of infections",
+ "grounding": [
+ {
+ "grounding_text": "percentage of cases",
+ "grounding_id": "cemo:percentage_of_cases",
+ "source": [],
+ "score": 0.8812347650527954,
+ "provenance": {
+ "method": "SKEMA-TR-Embedding",
+ "timestamp": "2023-06-15T22:59:11.975479"
+ }
+ }
+ ],
+ "extraction_source": {
+ "page": 0,
+ "block": 0,
+ "char_start": 94,
+ "char_end": 118,
+ "document_reference": {
+ "id": "buckymodel_webdocs.pdf"
+ }
+ },
+ "provenance": {
+ "method": "Skema TR Pipeline rules",
+ "timestamp": "2023-06-15T22:59:11.975409"
+ }
+ }
+ ],
+ "value_specs": [],
+ "groundings": []
+ }
+ }
+ ]
+ }
+ },
+ "amr_configuration": null,
+ "calibrated": false,
+ "calibration": null,
+ "calibration_score": null
+}
\ No newline at end of file
diff --git a/examples/calibrate_example2/request-calibrate2.json b/examples/calibrate_example2/request-calibrate2.json
new file mode 100644
index 0000000..960d120
--- /dev/null
+++ b/examples/calibrate_example2/request-calibrate2.json
@@ -0,0 +1,15 @@
+{
+ "modelConfigId": "55ca595f-940d-458c-9c73-7c315a10b559",
+ "dataset": {
+ "id": "a3365ea8-a199-49e1-b634-a1b3f8635731",
+ "filename": "sirFixed.csv",
+ "mappings": {
+ "t": "timestep",
+ "s": "S",
+ "i": "I",
+ "r": "R"
+ }
+ },
+ "extra": {},
+ "engine": "sciml"
+}
\ No newline at end of file
diff --git a/examples/calibrate_example2/sirFixed.csv b/examples/calibrate_example2/sirFixed.csv
new file mode 100644
index 0000000..71926ba
--- /dev/null
+++ b/examples/calibrate_example2/sirFixed.csv
@@ -0,0 +1,201 @@
+t,s,i,r
+0.0,0.99995,5E-05,0.0
+0.9045226130653270,0.9999360401998250,5.81428837853521E-05,5.81691638943948E-06
+1.8090452261306500,0.9999198054491840,6.76126650732997E-05,1.25818857422612E-05
+2.71356783919598,0.9999009552059880,7.86079359487088E-05,2.0436858062973E-05
+3.6180904522613100,0.9998790332211640,9.13947540566949E-05,2.95720247796426E-05
+4.522613065326630,0.9998535367124580,0.00010626629350235700,4.01969940395947E-05
+5.42713567839196,0.9998238896238350,0.00012355843011929300,5.25519460459022E-05
+6.331658291457290,0.9997894229731460,0.00014366119260970200,6.69158342437095E-05
+7.236180904522610,0.9997493586250260,0.00016702820812934200,8.3613166845046E-05
+8.14070351758794,0.9997027873643820,0.00019418945672409300,0.0001030231788942470
+9.045226130653270,0.9996486433453730,0.00022576614411472900,0.00012559051051197400
+9.949748743718590,0.9995856958202720,0.0002624754824149930,0.00015182869731353300
+10.85427135678390,0.9995125122498940,0.00030515212541540700,0.00018233562469026100
+11.758793969849200,0.999427442244904,0.0003547574836080150,0.0002178002714879780
+12.663316582914600,0.9993285545111150,0.0004124163353582550,0.00025902915352636200
+13.5678391959799,0.9992136020020600,0.0004794369796962950,0.0003069610182436060
+14.472361809045200,0.9990799973805680,0.0005573254481144330,0.00036267717131783900
+15.376884422110600,0.9989247124037400,0.000647843686089803,0.00042744391017004500
+16.28140703517590,0.99874425030346,0.0007530254860588380,0.0005027242104810540
+17.185929648241200,0.9985345358535610,0.0008752398138758120,0.0005902243325635600
+18.090452261306500,0.9982908382650760,0.0010172352471423400,0.0006919264877820160
+18.99497487437190,0.9980076847568090,0.0011821892535323800,0.000810125989659034
+19.899497487437200,0.9976787306814350,0.001373782731304410,0.0009474865872605980
+20.804020100502500,0.9972966191450990,0.0015962799505879200,0.0011071009043130300
+21.70854271356780,0.9968528292142720,0.0018546145992758800,0.0012925561864524700
+22.613065326633200,0.996337501198389,0.0021544887633450400,0.0015080100382661000
+23.517587939698500,0.9957392211887320,0.0025024933212454500,0.0017582854900232600
+24.42211055276380,0.9950448204028080,0.0029062206146677000,0.00204895898252419
+25.326633165829100,0.994239068774438,0.003374432680380340,0.002386498545181800
+26.231155778894500,0.993304440761098,0.003917190973063090,0.002778368265838980
+27.1356783919598,0.9922207146218560,0.004546070587462720,0.003233214790681540
+28.040201005025100,0.9909646893286790,0.005274313386069990,0.0037609972852510700
+28.944723618090500,0.9895096950388790,0.006117079668872510,0.004373225292248790
+29.84924623115580,0.9878252507210500,0.0070916263788088300,0.0050831229001411000
+30.753768844221100,0.985876489094241,0.008217583476694550,0.0059059274290645400
+31.658291457286400,0.9836237288730360,0.009517153830176030,0.006859117296787770
+32.56281407035180,0.9810219583851920,0.01101534170274800,0.007962699912059930
+33.46733668341710,0.9780202942013170,0.012740159947331500,0.0092395458513513
+34.37185929648240,0.9745615188541560,0.014722772385569600,0.010715708760274100
+35.27638190954770,0.9705816250458750,0.016997606196467400,0.012420768757657300
+36.18090452261310,0.9660095246031680,0.019602282638918000,0.014388192757914200
+37.085427135678400,0.9607668595046320,0.022577478474025500,0.0166556620213424
+37.98994974874370,0.954768070073712,0.025966543927421200,0.01926538599886700
+38.89447236180900,0.9479207531065240,0.029814882247734800,0.022264364645741800
+39.798994974874400,0.9401265381327690,0.034168918037237300,0.02570454382999370
+40.7035175879397,0.9312823382585810,0.03907478803326170,0.02964287370815750
+41.608040201005000,0.921282371997132,0.04457645518148410,0.03414117282138400
+42.51256281407040,0.9100208831008250,0.05071334463196500,0.03926577226720980
+43.41708542713570,0.8973956978667430,0.057517425486474900,0.04508687664678280
+44.321608040201000,0.8833126478274860,0.06500977301160790,0.05167757916090600
+45.22613065326630,0.8676908029929330,0.07319671244744660,0.05911248455962030
+46.13065326633170,0.8504683685155060,0.08206572988369910,0.06746590160079500
+47.03517587939700,0.8316089619830350,0.09158144268502220,0.076809595331943
+47.93969849246230,0.8111078483703180,0.101682025578239,0.08721012605144380
+48.84422110552760,0.7889975995340590,0.1122765480116080,0.09872585245433410
+49.74874371859300,0.7653524254333430,0.12324387019934400,0.11140370436731300
+50.653266331658300,0.7402907072772900,0.1344333222055870,0.1252759705171230
+51.55778894472360,0.7139749434828900,0.14566780569255700,0.14035725082455300
+52.462311557788900,0.6866088197744020,0.15674929152089900,0.15664188870470000
+53.366834170854300,0.6584313057969900,0.16746658190818800,0.17410211229482200
+54.2713567839196,0.6297079814623870,0.17760489409579900,0.19268712444181400
+55.175879396984900,0.6007202886152840,0.18695642462064700,0.21232328676407000
+56.08040201005030,0.5717536917709050,0.19533088062450300,0.2329154276045920
+56.98492462311560,0.5430856738835530,0.20256506014105200,0.25434926597539500
+57.88944723618090,0.514974769643344,0.20853047151733800,0.2764947588393190
+58.79396984924620,0.48765149841828700,0.21313836709318200,0.2992101344885320
+59.69849246231160,0.4613118019107160,0.21634188421460200,0.32234631387468200
+60.60301507537690,0.43611324226252300,0.2181353513947860,0.3457514063426910
+61.50753768844220,0.41217387907963000,0.21855112393243800,0.3692749969879320
+62.41206030150750,0.38957347890003100,0.21765453606312700,0.3927719850368430
+63.31658291457290,0.3683565330462640,0.21553766630211900,0.41610580065161700
+64.22110552763820,0.3485365066941480,0.21231256647767700,0.43915092682817500
+65.12562814070350,0.33010075857853000,0.20810455673826000,0.46179468468321000
+66.03015075376890,0.31301564967999500,0.203046027191173,0.4839383231288320
+66.93467336683420,0.29723147076152300,0.19727104760880200,0.505497481629675
+67.8391959798995,0.2826869362909430,0.19091093989958600,0.526402123809471
+68.74371859296480,0.2693130979397610,0.18409085379263400,0.5465960482676060
+69.64824120603020,0.2570366180613010,0.1769272988904980,0.5660360830482010
+70.55276381909550,0.24578240807235000,0.16952652704701900,0.5846910648806310
+71.4572864321608,0.23547567176043600,0.16198366169290100,0.6025406665466630
+72.36180904522610,0.22604343064408100,0.15438237255940800,0.6195741967965120
+73.26633165829150,0.21741561074975900,0.14679502811754200,0.6357893611327000
+74.17085427135680,0.20952576233256400,0.1392831687626700,0.6511910689047660
+75.07537688442210,0.2023114943891250,0.13189820197118500,0.6657903036396910
+75.97989949748740,0.19571468799209700,0.12468223617388700,0.6796030758340160
+76.88442211055280,0.18968154557357200,0.11766898430251600,0.6926494701239120
+77.78894472361810,0.18416252006380100,0.11088468887617700,0.7049527910600220
+78.69346733668340,0.17911215920362800,0.10434903316101600,0.7165388076353570
+79.59798994974880,0.17448889769599300,0.09807600800526070,0.7274350942987470
+80.50251256281410,0.1702548169308940,0.09207472086902000,0.7376704622000860
+81.4070351758794,0.16637538981584700,0.08635013685850830,0.7472744733256450
+82.31155778894470,0.1628192166255180,0.08090375070493970,0.7562770326695430
+83.21608040201010,0.15955777110665700,0.07573418328299190,0.7647080456103510
+84.12060301507540,0.1565651525659140,0.07083770784343380,0.7725971395906520
+85.0251256281407,0.15381785267551300,0.06620871324646510,0.7799734340780220
+85.92964824120600,0.15129453535591600,0.06184010374046490,0.7868653609036200
+86.83417085427140,0.1489758344140750,0.05772364096137000,0.7933005246245560
+87.73869346733670,0.14684416759897900,0.05385023860465670,0.7993055937963650
+88.64321608040200,0.14488356577373200,0.050210210305333000,0.8049062239209360
+89.54773869346730,0.14307951821844400,0.0467934763814549,0.8101270054001010
+90.45226130653270,0.14141883194167500,0.04358973863452240,0.8149914294238030
+91.35678391959800,0.13988950414861200,0.04058862409301680,0.8195218717583710
+92.26130653266330,0.13848060941595100,0.037779792651318300,0.8237395979327320
+93.16582914572870,0.137182193747867,0.03515304375034860,0.8276647625017850
+94.07035175879400,0.13598518287500500,0.03269838957820040,0.8313164275467950
+94.9748743718593,0.1348812985513170,0.030406100547738500,0.8347126009009450
+95.87939698492460,0.13386298233094900,0.028266764074053900,0.8378702535949970
+96.78391959799000,0.13292332914111900,0.02627130438923220,0.840805366469649
+97.68844221105530,0.13205602529657900,0.024411015100253600,0.8435329596031680
+98.5929648241206,0.13125529479331500,0.02267756803804890,0.8460671371686360
+99.49748743718590,0.130515849341737,0.02106302497275160,0.8484211256855120
+100.40201005025100,0.12983284381700500,0.019559836592371400,0.8506073195906240
+101.30653266331700,0.12920183625758900,0.01816084282490650,0.8526373209175050
+102.21105527638200,0.12861875234428300,0.016859266590848000,0.8545219810648690
+103.11557788944700,0.12807985224243000,0.015648705895858900,0.8562714418617120
+104.02010050251300,0.12758170136635300,0.014523122848773900,0.857895175784874
+104.92462311557800,0.12712114390634600,0.013476831692430000,0.8594020244012250
+105.82914572864300,0.12669527840577900,0.012504486376951600,0.8608002352172700
+106.73366834170900,0.1263014354480260,0.011601067954905900,0.8620974965970690
+107.63819095477400,0.12593715963945300,0.010761865189998200,0.8633009751705490
+108.5427135678390,0.1256001896000590,0.009982465140922990,0.8644173452590190
+109.44723618090500,0.12528844286874400,0.009258735463551640,0.8654528216677050
+110.35175879397000,0.12500000080993100,0.008586810294842440,0.8664131888952270
+111.25628140703500,0.1247330944551540,0.00796307731244616,0.8673038282324
+112.1608040201010,0.1244860934121840,0.007384160951479330,0.8681297456363370
+113.06532663316600,0.12425749343326300,0.006846911410962040,0.8688955951557750
+113.96984924623100,0.12404590684218500,0.006348389758200130,0.8696057033996150
+114.87437185929600,0.12385005295471200,0.005885855496933460,0.870264091548355
+115.77889447236200,0.12366874921916800,0.0054567550697293000,0.8708744957111030
+116.68341708542700,0.12350090411954300,0.005058709356757660,0.8714403865237000
+117.58793969849200,0.12334550926311900,0.004689503568101030,0.8719649871687810
+118.49246231155800,0.12320163320693900,0.0043470759911453800,0.8724512908019170
+119.39698492462300,0.12306841529961200,0.004029508236219720,0.8729020764641690
+120.30150753768800,0.12294506001713400,0.00373501611047972,0.8733199238723870
+121.20603015075400,0.12283083223368100,0.0034619403469983100,0.873707227419321
+122.1105527638190,0.12272505216903300,0.0032087386129387200,0.8740662092180280
+123.01507537688400,0.12262709151104800,0.0029739773033250500,0.8743989311856270
+123.91959798995000,0.12253636911101000,0.002756324479610610,0.8747073064093800
+124.82412060301500,0.1224523470299300,0.002554543251254460,0.8749931097188160
+125.7286432160800,0.12237452806017400,0.0023674843229456000,0.8752579876168810
+126.63316582914600,0.1223024524078130,0.002194080274916280,0.8755034673172710
+127.53768844221100,0.12223569432923900,0.002033340691780540,0.8757309649789810
+128.44221105527600,0.12217385986236600,0.0018843458554537100,0.8759417942821800
+129.3467336683420,0.1221165845445390,0.0017462416481079100,0.8761371738073540
+130.25125628140700,0.12206353130448900,0.0016182360865978900,0.8763182326089140
+131.15577889447200,0.12201438811378500,0.0014995942004442000,0.8764860176857710
+132.0603015075380,0.12196886561041400,0.0013896333757817100,0.8766415010138050
+132.96482412060300,0.12192669649592200,0.001287721019828220,0.8767855824842500
+133.86934673366800,0.1218876334237500,0.001193270433741780,0.8769190961425090
+134.77386934673400,0.12185144672730200,0.0011057366010980900,0.8770428166716000
+135.678391959799,0.12181792422720200,0.0010246146095967000,0.877157461163202
+136.58291457286400,0.1217868696345190,0.0009494364239913800,0.8772636939414900
+137.48743718593000,0.12175810067893800,0.000879767295209001,0.8773621320258540
+138.39195979899500,0.1217314488623900,0.0008152044996055680,0.8774533466380050
+139.2964824120600,0.12170675834133200,0.000755374914516739,0.8775378667441520
+140.20100502512600,0.12168388441070900,0.0006999319773823170,0.8776161836119090
+141.10552763819100,0.12166269320849200,0.0006485546281964740,0.8776887521633120
+142.01005025125600,0.12164306094413700,0.0006009455291177120,0.877755993526746
+142.9145728643220,0.1216248726896190,0.0005568285465920870,0.8778182987637900
+143.81909547738700,0.12160802206489500,0.0005159478215924570,0.8778760301135130
+144.72361809045200,0.12159241073900500,0.0004780665434248420,0.8779295227175710
+145.6281407035180,0.12157794748219100,0.0004429649187413820,0.877979087599068
+146.53266331658300,0.12156454767977200,0.00041043901233326100,0.8780250133078950
+147.43718592964800,0.12155213313493400,0.00038030014495283100,0.8780675667201140
+148.34170854271400,0.12154063141218800,0.0003523734335231050,0.8781069951542890
+149.2462311557790,0.12152997523578000,0.0003264964368431320,0.8781435283273770
+150.15075376884400,0.12152010243243500,0.00030251889846906500,0.8781773786690960
+151.05527638191000,0.12151095546315900,0.00028030167576997700,0.8782087428610710
+151.95979899497500,0.12150248085385300,0.00025971545828068300,0.8782378036878660
+152.8643216080400,0.1214946291530740,0.00024064058702368700,0.8782647302599020
+153.76884422110600,0.12148735462201100,0.000222966324077786,0.878289679053912
+154.67336683417100,0.12148061477849700,0.00020658980840517200,0.8783127954130980
+155.57788944723600,0.12147437027880900,0.0001914157441101740,0.8783342139770810
+156.4824120603020,0.1214685847433340,0.00017735597147342100,0.8783540592851930
+157.38693467336700,0.12146322442804600,0.00016432870367846800,0.8783724468682760
+158.29145728643200,0.12145825803224600,0.00015225806536713800,0.8783894839023870
+159.1959798994980,0.12145365662138400,0.00014107388765123800,0.8784052694909650
+160.10050251256300,0.12144939338817500,0.0001307111455974100,0.8784198954662280
+161.00502512562800,0.12144544344366000,0.00012110946534724600,0.8784334470909930
+161.90954773869300,0.12144178375555200,0.00011221295988510300,0.8784460032845640
+162.8140703517590,0.12143839301462500,0.00010396991112491500,0.8784576370742500
+163.71859296482400,0.12143525138510300,9.63321820779886E-05,0.878468416432819
+164.62311557788900,0.12143234056146400,8.92553331784974E-05,0.8784784041053580
+165.52763819095500,0.12142964364528200,8.26983264577703E-05,0.8784876580282610
+166.4321608040200,0.12142714501001100,7.66232035154706E-05,0.8784962317864740
+167.33668341708500,0.12142483003947600,7.09944801142567E-05,0.8785041754804100
+168.24120603015100,0.12142268522149000,6.57793388765391E-05,0.8785115354396340
+169.14572864321600,0.12142069800536500,6.09472913840077E-05,0.8785183547032510
+170.0502512562810,0.12141885673323000,5.64700151229083E-05,0.8785246732516470
+170.95477386934700,0.12141715080033000,5.23217447822067E-05,0.8785305274548880
+171.85929648241200,0.12141557026925500,4.84783351293002E-05,0.8785359513956160
+172.7638190954770,0.12141410584224200,4.4917194949796E-05,0.8785409769628090
+173.66834170854300,0.12141274886289600,4.16172909736009E-05,0.8785456338461310
+174.57286432160800,0.12141149159263500,3.85598125973904E-05,0.8785499485947680
+175.47738693467300,0.12141032674029000,3.57270385497828E-05,0.8785539462211600
+176.3819095477390,0.12140924747453600,3.31023659788911E-05,0.8785576501594860
+177.28643216080400,0.12140824743460600,3.0670335535197E-05,0.8785610822298590
+178.19095477386900,0.12140732090412200,2.84170496361095E-05,0.8785642620462420
+179.09547738693500,0.12140646250058600,2.63294234561324E-05,0.8785672080759580
+180.0,0.12140566717345900,2.43951796271236E-05,0.8785699376469140
\ No newline at end of file
diff --git a/src/SimulationService.jl b/src/SimulationService.jl
index 57d3886..b4961cf 100644
--- a/src/SimulationService.jl
+++ b/src/SimulationService.jl
@@ -299,7 +299,7 @@ function get_dataset(obj::JSON3.Object)
s3_url = get_json(tds_url).url
df = CSV.read(download(s3_url), DataFrame)
return haskey(obj, :mappings) ?
- rename!(df, Dict{String,String}(obj.mappings)) :
+ rename!(df, Dict(string(k) => string(v) for (k,v) in obj.mappings)) :
df
end
diff --git a/src/operations.jl b/src/operations.jl
index 7226c33..825abe4 100644
--- a/src/operations.jl
+++ b/src/operations.jl
@@ -70,10 +70,10 @@ end
# data
function amr_get(df::DataFrame, sys::ODESystem, ::Val{:data})
-
+ @info "parse dataset into calibrate format"
statelist = states(sys)
statenames = string.(statelist)
- statenames = map(statenames) do n; n[1:end-3]; end # there's a better way to do this
+ statenames = [replace(nm, "(t)" => "") for nm in statenames]
tvals = df[:,"timestamp"]
map(statelist, statenames) do s,n
@@ -128,8 +128,8 @@ end
function solve(op::Simulate; kw...)
# joshday: What does providing `u0 = []` do? Don't we know what u0 is from AMR?
- prob = ODEProblem(op.sys, [], op.timespan, saveat=1)
- sol = solve(prob; progress = true, progress_steps = 1, kw...)
+ prob = ODEProblem(op.sys, [], op.timespan)
+ sol = solve(prob; progress = true, progress_steps = 1, saveat=1, kw...)
@info "Timesteps returned are: $(sol.t)"
dataframe_with_observables(sol)
end
@@ -198,11 +198,11 @@ function solve(o::Calibrate; callback)
fit = EasyModelAnalysis.datafit(prob, init_params, o.data)
else
init_params = Pair.(EasyModelAnalysis.ModelingToolkit.Num.(first.(o.priors)), tuple.(minimum.(last.(o.priors)), maximum.(last.(o.priors))))
- fit = global_datafit(prob, init_params, o.data)
+ fit = EasyModelAnalysis.global_datafit(prob, init_params, o.data)
end
- newprob = remake(prob, p=fit)
- sol = solve(newprob)
+ newprob = EasyModelAnalysis.DifferentialEquations.remake(prob, p=fit)
+ sol = EasyModelAnalysis.DifferentialEquations.solve(newprob; saveat = 1)
dfsim = DataFrame(hcat(sol.t,stack(sol[statenames])'), :auto)
rename!(dfsim, ["timestamp";string.(statenames)])
diff --git a/test/runtests.jl b/test/runtests.jl
index 75f8d28..280f964 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -21,15 +21,15 @@ here(x...) = joinpath(dirname(pathof(SimulationService)), "..", x...)
#-----------------------------------------------------------------------# JSON payloads for testing
# route => payload
simulate_payloads = JSON3.write.([
- (local_model_file=here("examples", "BIOMD0000000955_askenet.json"), timespan = (; start=0, var"end"=100)),
+ (local_model_file=here("examples", "calibrate_example1", "BIOMD0000000955_askenet.json"), timespan = (; start=0, var"end"=100)),
])
calibrate_payloads = JSON3.write.([
let
- (; engine, timespan, extra) = JSON3.read(read(here("examples", "request-calibrate-no-integration.json")))
+ (; engine, timespan, extra) = JSON3.read(read(here("examples", "calibrate_example1", "request-calibrate-no-integration.json")))
(;
- local_csv_file = here("examples", "dataset.csv"),
- local_model_file = here("examples", "BIOMD0000000955_askenet.json"),
+ local_csv_file = here("examples", "calibrate_example1", "dataset.csv"),
+ local_model_file = here("examples", "calibrate_example1", "BIOMD0000000955_askenet.json"),
engine, timespan, extra
)
@@ -46,7 +46,7 @@ end
#-----------------------------------------------------------------------------# AMR parsing
@testset "AMR parsing" begin
- file = here("examples", "BIOMD0000000955_askenet.json")
+ file = here("examples", "calibrate_example1", "BIOMD0000000955_askenet.json")
amr = JSON3.read(read(file))
sys = SimulationService.amr_get(amr, ODESystem)
@test string.(states(sys)) == ["Susceptible(t)", "Diagnosed(t)", "Infected(t)", "Ailing(t)", "Recognized(t)", "Healed(t)", "Threatened(t)", "Extinct(t)"]
@@ -58,7 +58,7 @@ end
@test string.(first.(priors)) == string.(parameters(sys))
@test last.(priors) isa Vector{Uniform{Float64}}
- df = CSV.read(here("examples", "dataset.csv"), DataFrame)
+ df = CSV.read(here("examples", "calibrate_example1", "dataset.csv"), DataFrame)
data = SimulationService.amr_get(df, sys, Val(:data))
@test data isa Vector{Pair{SymbolicUtils.BasicSymbolic{Real}, Tuple{Vector{Int64}, Vector{Float64}}}}
@test string.(first.(data)) == string.(states(sys))
@@ -129,11 +129,11 @@ end
@test extrema(df.timestamp) == (0.0, 99.0)
end
@testset "calibrate" begin
- file = here("examples", "BIOMD0000000955_askenet.json")
+ file = here("examples", "calibrate_example1", "BIOMD0000000955_askenet.json")
amr = JSON3.read(read(file))
sys = SimulationService.amr_get(amr, ODESystem)
priors = SimulationService.amr_get(amr, sys, Val(:priors))
- df = CSV.read(here("examples", "dataset.csv"), DataFrame)
+ df = CSV.read(here("examples", "calibrate_example1", "dataset.csv"), DataFrame)
data = SimulationService.amr_get(df, sys, Val(:data))
num_chains = 4
num_iterations = 100
@@ -146,6 +146,18 @@ end
statenames = [states(o.sys);getproperty.(observed(o.sys), :lhs)]
@test names(dfsim) == vcat("timestamp",reduce(vcat,[string.("ensemble",i,"_", statenames) for i in 1:size(dfsim,2)÷length(statenames)]))
@test names(dfparam) == string.(parameters(sys))
+
+ #calibrate_method = "local"
+ #o = SimulationService.Calibrate(sys, (0.0, 89.0), priors, data, num_chains, num_iterations, calibrate_method, ode_method)
+ #dfsim, dfparam = SimulationService.solve(o; callback = nothing)
+
+ calibrate_method = "global"
+ o = SimulationService.Calibrate(sys, (0.0, 89.0), priors, data, num_chains, num_iterations, calibrate_method, ode_method)
+ dfsim, dfparam = SimulationService.solve(o; callback = nothing)
+
+ statenames = [states(o.sys);getproperty.(observed(o.sys), :lhs)]
+ @test names(dfsim) == vcat("timestamp",string.(statenames))
+ @test names(dfparam) == string.(parameters(sys))
end
end
diff --git a/test/tds.jl b/test/tds.jl
index 1628b28..cccba2b 100644
--- a/test/tds.jl
+++ b/test/tds.jl
@@ -35,7 +35,8 @@ datasets = get_json("$(TDS_URL[])/datasets")
data_obj = JSON3.read(JSON3.write((;
id = datasets[1].id,
name = datasets[1].name,
- filename = datasets[1].file_names[1]
+ filename = datasets[1].file_names[1],
+ mappings = (; Ailing = "A")
)))
get_dataset(data_obj)