metawards / MetaWards

MetaWards disease metapopulation analysis and modelling software. Professional geographical SIR model with a flexible plugin architecture to support complex scenario modelling
https://metawards.org
GNU General Public License v3.0
13 stars 6 forks source link

[BUG] - cannot build network from custom network files #180

Closed mlt39 closed 3 years ago

mlt39 commented 3 years ago

Hi, I'm trying to create a custom network by creating network files as detailed here: https://metawards.org/fileformats/network.html I have tried a very simple 2-node network, but model runs terminate with no error during the "Building the network" stage.

To reproduce

  1. Run the model results = mw.run(model='simple', disease=flu, output="output", force_overwrite_output=1, additional=10)
  2. Network files are in my directory "MetaWardsData/model_data/simple". You can find a copy of the files here: https://github.com/mlt39/MetaWards
  3. Terminates with no error after the lines
    ---------------------------- Building the network -----------------------------
    Reading C:\Users\ethyl\GitHub\MetaWardsData\model_data\simple\work.dat into 
    memory...

However running the example networks e.g. "2011Data" work: results = mw.run(model='2011Data', disease=flu, output="output", force_overwrite_output=1, additional=10) but once I edit the network, e.g. directly edit the 2011Data files to reduce it to a simple 2-node network, building the network terminates again.

Environment:

chryswoods commented 3 years ago

Sorry for the delay in replying - leave followed by running a major conference.

I've taken a look and the issue is because your data files had errors.

In description.json you need to use zero-indexing for the column numbers, e.g.

  "lookup_columns"     : {"code":0, "name":1}

And then for lookup.dat you need to use commas to separate out the columns, e.g.

lad17cd, lad17nm
E06000001, Hartlepool
E06000002, Middlesbrough

You can see the error messages if you run the metawards executable directly, e.g.

metawards -d 2011Data

if you are overwriting the 2011Data. I don't recommend this. Instead, I recommend that you create a new directory, e.g. TestData, which is in the same directory as 2011Data, and then copy the files into there. You can then use this data by passing in the name of the directory, e.g.

metawards -d TestData

In general though, I don't recommend that you write data files like this. These files are very picky as they are in a legacy format. We have a much nicer way now of creating models. This is a Python or R API that lets you build the model programmatically. There are checks included to help prevent these kinds of errors, and the model is then written to JSON as a single file, thereby making it a lot more robust.

This is described in the quick start guide (https://metawards.org/quickstart/01_R.html#creating-the-wards-network for R and https://metawards.org/quickstart/01_python.html#creating-the-wards-network for Python). It is also described in more detail in the tutorial (https://metawards.org/tutorial/index_part08.html), plus we have full docs of the API (https://metawards.org/api/index_api_MetaWards.html#metawards.Wards - you are looking for Ward, Wards etc.)

chryswoods commented 3 years ago

Closing as no activity and the issue is predominantly a data formatting problem in the input files. Please feel free to reopen if there is anything you want to add.