0

I am trying to fit one function to another function by adjusting two parameters. But I dont know the form of this function. I have only cost function because for computation of this function is used LAMMPS (molecular dynamics). I need some tool which i can give only cost function and my guess and then it would minimize it.

I was looking on SciPy optimization but it looks like it needs the original function which i dont have.

n5ver
  • 5
  • 5
  • Do you mean something like gradient descent? – Eka Jul 24 '19 at 10:13
  • 1
    your question is s little vague without at least some code or a better technical explaination of what you have so far – DrBwts Jul 24 '19 at 10:15
  • I have function as set of Xs and Ys which is computed in one program (VASP) and then I have to get similar function (also set of Xs and Ys) from LAMMPS by tuning two parameters. I can compute how different they are to each other (cost function) but i just need something to minimize this cost function. Right now i dont have any code. – n5ver Jul 24 '19 at 14:47

1 Answers1

0

A function approximation algorithm needs you to make a few assumptions about how your mathematical model behaves.

If you see things from a black box point of view, three scenarios can occur -

X -> MODEL -> Y

  1. You have the X and MODEL, but you dont have the Y; This is simulation
  2. You have the MODEL and Y, but you dont have the X; This is Optimization
  3. You have the X and Y, but you dont have the MODEL; This is mathematical modelling

However there is a catch. You can NEVER do 3. directly. Instead you use a trick to reframe the 3. as a 2. (optimization problem). The trick is to say that you assume your model to be something like y=mx+c, and then instead of finding the model you find new inputs m and c. Thus, we can instead say -

  1. You have the (MODEL, X) and Y but you dont have M,C (New inputs); This is optimization as well.

(M,C) -> (MODEL + X) -> Y

This means, that even if you dont know the input function, you have to assume some model and then estimate the parameters which when tuned, let the model behave as the close to the input function as possible.

Basically, what you need is machine learning. You have the inputs, you have the outputs (or you can get them but running your first function with a large sample of outputs), you have the cost function. Assume a model, and train it to approximate your input function.

If you are not sure what to use, then use a generalized function approximator AKA neural networks. But beware, it needs a lot more data to train.

Akshay Sehgal
  • 18,741
  • 3
  • 21
  • 51
  • I have function as set of Xs and Ys which is computed in one program (VASP) and then I have to get similar function (also set of Xs and Ys) from LAMMPS by tuning two parameters. I can compute how different they are to each other (cost function) but i just need something to minimize this cost function. – n5ver Jul 24 '19 at 12:54
  • So you have input data and output data? Or you have a function? (VASP). Can you elaborate a little? Also, what is your cost function doing? By definition a cost function takes the ACTUAL Y and PREDICTED/COMPUTED Y and calculates the difference between them. Is that what you have? – Akshay Sehgal Jul 25 '19 at 11:21
  • I have two sets of point (x and y values) one is from VASP and i know that it is right. Second is from LAMMPS and I have to tune two parametrs to make the second one like that from VASP. As cost function I use correlation betwen them. – n5ver Jul 26 '19 at 12:15
  • Ok, couple more questions based on your previous comment. 1. What is the"second one" exactly, you say you wante to tune 2 parameters to make the 'second one' like that from VASP. 2. As cost function you use correlation between what exactly, you only mention "them". – Akshay Sehgal Jul 26 '19 at 12:18
  • I use correlation between function values. I use correlation from scipy.spatial.distance.correlation – n5ver Jul 27 '19 at 20:05