Python Forum
Optimization using scipy.optimize - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Optimization using scipy.optimize (/thread-35672.html)



Optimization using scipy.optimize - KaneBilliot - Nov-30-2021

The original problem is as follows:
I have a line function that depends on two values (let's call them a and b) that I am using to fit 3 points. Note that I do not know the exact values of these points. However, what I have are their standard deviations (let's call them c, d, and e) based on the fit. So, for a given combination of a and b, I get different values of c, d, and e. The goal is to find a combination of a and b such that c, d, and e are the smallest. Manually, one can keep inputting different combinations of a and b until the smallest values of c, d, and e are achieved.

Given the repetitive nature of the problem, I want to try to automate this process. In terms of an algorithm, I am trying to use a table of c, d, and e for different values of a and b that I have to find out when c, d, and e are the smallest. I have looked at some functions of scipy.optimize, particularly the minimize function, but it does not seem like the best thing to use for this purpose since the minimize function requires a function whose variables are to be minimized. What I have tried to do is define a function that returns sqrt(c**2 + d**2 + e**2) and then pass that function to the minimize function, but this would obviously ignore the table of values that I currently have. What should I do differently so that I can use scipy.optimize.minimize? Or is there another python library that better solves this problem?


RE: Optimization using scipy.optimize - Gribouillis - Nov-30-2021

How are c, d, e computed in terms of a and b?


RE: Optimization using scipy.optimize - KaneBilliot - Nov-30-2021

(Nov-30-2021, 07:11 AM)Gribouillis Wrote: How are c, d, e computed in terms of a and b?

c, d, and e are not computed. They are given data points.


RE: Optimization using scipy.optimize - Gribouillis - Nov-30-2021

KaneBilliot Wrote:So, for a given combination of a and b, I get different values of c, d, and e. The goal is to find a combination of a and b such that c, d, and e are the smallest.
This sentence implies that there is a dependency relation between a, b and the values of c, d, e. This is the missing part in your description of the problem. How do you get the values of c, d, e for a given combination of a, b?