Using genetic algorithm for parameter optimization in MSX

Hi Everyone,
I have a water quality prediction model that can predict cl residual in the water distribution network. this model is a differential equation like below:
dcl/dt=function (time, cl, pipe diameter, mass transfer coefficient, Reynolds number)

In this model, there are three constant coefficients (A, B, C) that could be adjusted in order to predict cl residual in the network precisely. I have a few measurements of cl residual in different points of the water distribution network and I want to use these measurements to find my optimum model coefficients.
I would like to use the genetic algorithm (GA) in Matlab to adjust my model coefficients by minimizing the error between my predictions and network measurements that I have. but I need to know if something like this is doable? I have a network with more than 500 nodes and more than 3000 pipes. can I do water quality analysis with MSX/Matlab/GA?
I would appreciate if someone could help me.


Yes It’s possible, but note the network size is big and the run of optimization program will be slow. You can skeletonize your network before using in optimization.
I you want to calibrate your network based chorine residual parameter, doesn’t need MSX and only you can use EPANET.

1 Like

Thank you very much for your response Alireza. How can I use EPANET instead of MSX?
Can you please help me with the functions I should use for this purpose?

when I use MSX in Matlab for water quality analysis to see chlorine residual in different nodes, this error pops up:
Error using epanet/getMSXError (line 9488)
Please check the MSX file. Maybe node/link ids do not exist in the input file.

my input file is correct and it can run in EPANET… should I write some information manually in Matlab or everything is automatically transferred from EPANET to Matlab? (like pipe diameters, length, etc.)

I would really appreciate it if I could have your LinkedIn or email address for asking questions.
Thank you very much,
Linkedin: faezeh absalan

Sure, Please sent your file to my email.
However, I think you can solve your problem with EPANET alone.
my email is:

1 Like

Thank you very much. I sent you my file.