Optimizing error when there is more than one component

I am getting an error when optimizing the binding model parameter for a system consisting of two components, a salt and a protein (designated as object A). Increasing the number of components seems to be the cause of the error, as it worked fine when there was only one component. Can anyone tell me why I am getting the error below and what I am doing wrong? I’m using CADET-process.


TypeError Traceback (most recent call last)
Cell In[31], line 2
1 if name == ‘main’:
----> 2 optimization_results = optimizer.optimize(
3 optimization_problem,
4 use_checkpoint=False
5 )

File c:\ProgramData\miniconda3\envs\cadet\lib\site-packages\CADETProcess\optimization\optimizer.py:210, in OptimizerBase.optimize(self, optimization_problem, x0, save_results, results_directory, use_checkpoint, overwrite_results_directory, exist_ok, log_level, reinit_cache, delete_cache, *args, **kwargs)

→ 103 raise TypeError(f"Expected {self.ty}")
105 if recursive:
106 return super()._check(value, recursive)

TypeError: Expected <class ‘list’>

This file is part of the full code.
Error_simulation.ipynb (7.5 KB)

Hi, could you please provide a fully reproducible example? Currently, I don’t have access to the experimental data.

Hi Schmoelder, Thanks for the reply.

I’ve attached the full code below.
LWE fitting_error.ipynb (11.2 KB)

Due to data security issue, I used a dataset which I made up myself and still, the same error occurs.
Can you please tell me what could be causing the error?

Best, Jay

Hi Jay,

Jo was busy so I had a look.

The TypeError: Expected <class ‘list’> comes from giving the optimization_problem a variable in a multicomponent system without specifying the component. Therefore the optimization_problem will try to set the variable (e.g. ka) for all components and therefore expect a “list” input but gets a float input. To fix: add component_index=1 to your add_variable call. (That is, assuming you want to modify the parameters of your Protein “A” which has index 1 and not the parameters of the salt component, which has index 0).

Three other things:

  1. The MRE you supplied didn’t work for J.schmoelder and me, because the dataframe contained NaN’s, which caused problems for CADET Process. In the attached modified .ipynb. I’ve added a change to remove the NaN’s.
  2. You added the salt concentration to the reference and the comparator. Was that done on purpose? Do you want to use differences in the salt concentration curve to fit the parameters of the protein? I assumed not and fixed that with changes 2&3 in the .ipynb by adding components = [“A”] to the add_difference_metric() call.
  3. If you want to use parallelization to speed up the optimization, you can use this code:
optimizer = U_NSGA3()
optimizer.n_cores = 4

to use e.g. 4 cores (or more, depending on your system). If that causes a crash, you can update CADET-Process to an unreleased version with a mulitprocessing-fix using this command:

pip install -e git+https://github.com/fau-advanced-separations/CADET-Process.git@07256cf54459e1f60bd3792f1114eae9c8b6e10c#egg=CADET-Process

Here’s the ipynb with all the changes.

LWE fitting_error.ipynb (256.3 KB)


Hi Ronald.
The ipynb file you revised works perfectly and is just what I was looking for. I’ve also confirmed that the unreleased version of the CADET Process is functioning really well.
Thanks a lot for your help. Best of luck with your work!

Best, Jay