简体   繁体   中英

Minimization values for a function

I have got function - non linear(I thk), and a set of variable

S=[(x1,y1),(x2,y2)...] .

The objective is to find the value for x and y such that

sum of( max(|x-xi|,|y-yi|) for each (xi,yi) element of S is minimized and | | represents absolute value .

I came across a function optimize() in python but I don't really know if that works for this case. Is there any algorithm I can code myself to find the solution ie x and y.

eg : S=[(1,4),(2,3),(0,1),(1,1)]

for x=1.5 and y=2.5(and some other values as well) the function gives the minimum value : 5
max(|1.5-1|,|2.5-4|)=1.5
max(|1.5-2|,|2.5-3|)=0.5
max(|1.5-0|,|2.5-1|)=1.5
max(|1.5-1|,|2.5-1|)=1.5
sum:5.0

if '{' can be replaced by '[',it will be much easier to understand.It means a list store tuples.your purpose is to find the minimum in (|x-xi|,|y-yi|) and sum the minimum ? If i do not misunderstand your purpose,we can do like this: assume x=5 y=5 sum=0 for elem in s: sum = sum+(abs(5-elem[0])>abs(5-elem[1]) and abs(5-elem[1]) and abs(5-elem[0]))

this is what you want ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM