WassimTenachi / PhySO

Physical Symbolic Optimization

Home Page:https://physo.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to fit a function I wanted

Noctise opened this issue · comments

Hi Wassim

I have a model: log(k)= v*(x1c1log(t1)+(1-x1)c2log(t2) ) + (1-v)log(c0t0)

it’s doesn’t work now, so I wanna build a new function like f(x1,c1log(t1),c2log(t2)) * log(k) = v(x1c1log(t1)+(1-x1)c2log(t2) ) + (1-v)log(c0t0)

could I use physo to fit f(x1,c1*log(t1),c2log(t2)) And follow the formula above?

if its ok,how to set the training parameter0.0?

thanks

The variable is v,x1,output is log(k)

Hi @Noctise,

Yes, physo is adapted to this type of problem as it can find a free-form symbolic analytical function $f: \mathbb{R}^n \longrightarrow \mathbb{R}$ that fits $y = f(x_0,..., x_n)$ given $(x_0,..., x_n, y)$ data.

Can checkout the getting started tutorial in the readme and tell me if that's answers you question ?

Wassim

Hi @Noctise,
Can you tell me if you were able to follow the getting started tutorial so I can clos the thread ?
Thank you

Hi Wassim

Sorry, I didn't understand the examples in the document. What do x, which is set to [[1,0,0], [1,-1,0]], y, and fixed_consts mean?

These are the parameters I used, but the results were not satisfactoryT_T.

expression, logs = physo.SR(X, y,
                            X_names = [ "v"       , "x1"      ],
                            X_units = [ [1, 0, 0] , [1, -1, 0]],
                            y_name  = "K",
                            y_units = [2, -2, 1],
                            fixed_consts       = [ 1.      ],
                            fixed_consts_units = [ [0,0,0] ],
                            free_consts_names = [ "C1log(t1)", "C2log(t2)", "log(c0t0)" ],
                            free_consts_units = [ [0, 0, 1],      , [0, 0, 1],      [0, 0, 1] ],
                            op_names = ["mul", "add", "div", "n2", "sqrt", "exp", "log"],
                            run_config = physo.config.config1.config1                    
)

Hi @Noctise,

These are the units of the input variables. Eg:
[1,0,0] is length
[1,-1,0] is length.(time)^(-1) ie a velocity

Do you have physical units in your problem, is x a length or v a velocity for example ?
If it is not the case, you can leave all units arguments to their default values using:


expression, logs = physo.SR(X, y,
                            X_names = [ "v"       , "x1"      ],
                            y_name  = "K",
                            fixed_consts       = [ 1.      ],
                            free_consts_names = [ "C1log(t1)", "C2log(t2)", "log(c0t0)" ],
                            op_names = ["mul", "add", "div", "n2", "sqrt", "exp", "log"],
                            run_config = physo.config.config1.config1                    
)

Fixed constants are constants which's values are fixed (ie. not adaptative) eg. 1, pi etc they are distinct from free constants eg. c0, c1 which's values are optimised to fits as best as possible X,y given a trial functional form.

Hi @Noctise, did this documentation answer you question ?
Please tell me so I can close this issue.

Hi Wassim
That is your answer "
These are the units of the input variables. Eg:
[1,0,0] is length
[1,-1,0] is length.(time)^(-1) ie a velocity" I had understood,
while I didn't understand the free_consts_units [0,0,1] is mean that the default units?

Best wishes and looking forward to your reply.

Arbitrarily considering that the units vector stands for [length, time, mass],
Having a free constants of units [0,0,1] would mean having a free constant mass.

If your problem is not related to physics or physical engineering (where variables and constants have units like length, velocity, mass, temperature etc.) you should simply put every units to [0,0,0] so your data can be treated as dimensionless.

Does that answer your question ?

  1. Regarding units, you can choose any convention you like ! You can choose to use units as [length, time, mass...] or [mass, length, time ...], it won't change anything regarding the units analysis performed by physo as long as you use a consistent convention for y, free constants, fixed constants and components of X.
    Angles are dimensionless in the context of dimensional analysis so you can put [0,0,0] for your angles.

  2. The physical units prior is not learned but determined by our algorithm which performs units analysis following dimensional analysis rules on the fly on equations while they are generated. The details are in algo 1 of the paper: https://arxiv.org/pdf/2303.03192.pdf with implementation in: physo/physym/dimensional_analysis.py

Hi @WassimTenachi

I have not yet achieved the desired outcome.
I am currently perusing the source code that you have published and endeavoring to comprehend it, which may require a substantial amount of time.
I will continue to monitor physo, and should any documentation that you produce subsequently prove useful to me, I will persist in my efforts.

By the way, I specialize in the study of chemical materials, and it is possible that some of the parameters may be using outdated units that are no longer applicable to current formulas, leading to dimensional issues.

Lastly, thank you for your response^_^.
(You may now close this issue)

Ok @Noctise, good luck with that !
I did a bit of chemistry myself, I know that in chemistry proxy units are often used which my lead to inconsistencies for physo.
If you want to understand the method, I recommend looking at files in physym first in that order: token, functions, program, free const, dimensional analysis, execute, prior, reward, dataset and then batch. Unit test can be helpful for understanding too !
Cheers !