Error while running Lesson 8 Cadet Match

I am new here in this forum, beginner in cadet. I have completed all the tutorials of Cadet (Python based) and now moved to cadet match. Getting error in Lesson 8 cadet match tutorial. I am using in macOS.
Error screen shot attached herewith. Please someone help this regard.
Thank you

Hey,
could you please post the entire error message or even the entire script?
Best
Johannes

Hello,
please see complete script (Lesson:8 Cadet match). Sorry for the delay.

#Example: Automatic determination of porosity and axial dispersion of a Column

%run ../utils.ipynb

from addict import Dict

base_dir = Path('./').absolute()

match_config = Dict()
match_config.CADETPath = Cadet.cadet_path
match_config.baseDir = base_dir.as_posix()
match_config.resultsDir = 'results'

dextran_model = create_dextran_model()
run_simulation(dextran_model, 'dextran_reference.h5')

parameter1 = Dict()
parameter1.location = '/input/model/unit_001/COL_DISPERSION'
parameter1.min = 1e-10
parameter1.max = 1e-6
parameter1.component = -1
parameter1.bound = -1
parameter1.transform = 'null'

parameter2 = Dict()
parameter2.location = '/input/model/unit_001/COL_POROSITY'
parameter2.min = 0.2
parameter2.max = 0.7
parameter2.component = -1
parameter2.bound = -1
parameter2.transform = 'null'

match_config.parameters = [parameter1, parameter2]


experiment1 = Dict()
experiment1.name = 'dextran'
experiment1.csv = '../resources/dextran_experiment.csv'
experiment1.HDF5 = 'dextran_reference.h5'
experiment1.output_path = '/output/solution/unit_002/SOLUTION_OUTLET_COMP_000'

match_config.experiments = [experiment1,]


feature1 = Dict()
feature1.name = "Pulse"
feature1.type = 'SSE'

experiment1.features = [feature1,]


match_config.searchMethod = 'NSGA3'
match_config.population = 12
match_config.stallGenerations = 10
match_config.finalGradRefinement = True
match_config.gradVector = True

#Saving the config and running the optimization

from CADETMatch.jupyter import Match

match_config_file = base_dir / 'dextran.json'

with open(match_config_file.as_posix(), 'w') as json_file:
    json.dump(match_config.to_dict(), json_file, indent='\t')

match = Match(match_config_file)
match.start_sim()

#Create corner plots

match.plot_corner()

#Best plots

match.plot_best()

Please have a look. @j.schmoelder
Thank you

Hey,
sorry for the late reply, I was travelling. I will have a look later.

Ok, I think I found the issue. If you look at the error message, it says:

----> 6     json.dump(match_config.to_dict(), json_file, indent='\t')
[...]
TypeError: Object of type PosixPath is not JSON serializable

So what I did next was to check the contents of match_config. This is the output when i print it:

{'CADETPath': PosixPath('/opt/tljh/user/bin/cadet-cli'),
 'baseDir': '/home/jupyter-j.schmoelder/cadet-tutorial/08_CADET-Match_Introduction',
 'resultsDir': 'results',
 'parameters': [{'location': '/input/model/unit_001/COL_DISPERSION',
   'min': 1e-10,
   'max': 1e-06,
   'component': -1,
   'bound': -1,
   'transform': 'null'},
  {'location': '/input/model/unit_001/COL_POROSITY',
   'min': 0.2,
   'max': 0.7,
   'component': -1,
   'bound': -1,
   'transform': 'null'}],
 'experiments': [{'name': 'dextran',
   'csv': '../resources/dextran_experiment.csv',
   'HDF5': 'dextran_reference.h5',
   'output_path': '/output/solution/unit_002/SOLUTION_OUTLET_COMP_000',
   'features': [{'name': 'Pulse', 'type': 'SSE'}]}],
 'searchMethod': 'NSGA3',
 'population': 12,
 'stallGenerations': 10,
 'finalGradRefinement': True,
 'gradVector': True}

Here you can see that actually, the cadet path seems to be the culprit. If you convert it to a proper path, it runs:

match_config.CADETPath = Cadet.cadet_path.as_posix()

Once again, sorry it took so long!

It’s working now by changing path. Thank you for your help. I got the results.

1 Like