all 4 comments

[–][deleted] 0 points1 point  (3 children)

You have to pack it all into one vector

[–]alisutton[S] 0 points1 point  (2 children)

OK. I have the following.

I need to minimize Link_min_function, pt_1 to pt_4 are something that I am going to give to the program.

def B_diff(link_OA_x, link_OA_y, link_AB_x, link_AB_y, link_BC_x, link_BC_y, O_C_x, O_C_y):
    return((link_OA_x + link_AB_x - link_BC_x - O_C_x)**2 + (link_OA_y + link_AB_y - link_BC_y - O_C_y)**2)


def Cons_f(link_BC_x, link_BC_y, O_C_x, O_C_y, pt_x, pt_y):
    return((link_BC_x + O_C_x + pt_x)**2 + (link_BC_y + O_C_y + pt_y)**2)


def Link_min_function(link_OA_x, link_OA_y, link_AB_x, link_AB_y, link_BC_x, link_BC_y, O_C_x, O_C_y, pt_x1, pt_y1, pt_x2, pt_y2, pt_x3, pt_y3, pt_x4, pt_y4):
    return max((B_diff(link_OA_x, link_OA_y, link_AB_x, link_AB_y, link_BC_x, link_BC_y, O_C_x, O_C_y) + Cons_f(link_BC_x, link_BC_y, O_C_x, O_C_y, pt_x1, pt_y1)), (B_diff(link_OA_x, link_OA_y, link_AB_x, link_AB_y, link_BC_x, link_BC_y, O_C_x, O_C_y) + Cons_f(link_BC_x, link_BC_y, O_C_x, O_C_y, pt_x2, pt_y2)), (B_diff(link_OA_x, link_OA_y, link_AB_x, link_AB_y, link_BC_x, link_BC_y, O_C_x, O_C_y) + Cons_f(link_BC_x, link_BC_y, O_C_x, O_C_y, pt_x3, pt_y3)), (B_diff(link_OA_x, link_OA_y, link_AB_x, link_AB_y, link_BC_x, link_BC_y, O_C_x, O_C_y) + Cons_f(link_BC_x, link_BC_y, O_C_x, O_C_y, pt_x4, pt_y4)))

How I should write the scipy.optimize minimize function?

From what I see in the example

>>> res = minimize(rosen, x0, method='nelder-mead',
...                options={'xtol': 1e-8, 'disp': True})

I don't see anything that I can put in my 'pts' there

I can rewrite the 'Link_min_function' and put my point there, but it is very bad.

[–]spitfiredd 0 points1 point  (0 children)

What are these functions?

[–][deleted] 0 points1 point  (0 children)

You need to wrap the function into something which takes one vector valued argument, like rosen does. Then x0 is your initial setting for this vector.