Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k views
in Technique[技术] by (71.8m points)

python - Optimize multiple one-variable functions with same variable

I have quite a complicated function based on a table input. The maximum of certain columns are end-results (2 in total). These columns are dependent on eachother and other columns.

I need to iteratively optimize the maximum of multiple columns to specific values, so that none of these column-maxima exceeds the specific value.

The input table snippet (many rows)

Column A, Column B
542.64, 8.5
540.00, 8.5
541.00, 8.6
654.23, 4.7

Calculations

Column C = c1*((c2+(x*column A)^2) / (c1 + c2))^c3
Column D = Column D[n-1]*(1-c4) + (Column B + Column C)*c4 #Startvalue is given
column E = c5*(x*column A)^c6
Column F = Column F[n-1]*(1-c7) + Column E*c7
Column G = Column D + Column F

where c1 to c7 are constants

Solve for X until all conditions are met, and at least one =< closely approaches to be =:

condition 1 = max(Column D) =< value1
condition 2 = max(Column F) =< value2
condition 3 = max(x*Column A) =< value3

I do not want to use if-else statements like this:

solve x for max(column D) == value1

if condition 2 == True and condition 2 == True:
    return x
else solve x for max(column F) == value2
    if condition 3 == True
        return x
    else solve x for max(column G) == value3
        return x

*Note: Instead of full on column calculations I calculate the end-results of a few columns as lists

*Note 2: I use a for-loop because the caculations use the n-1 value (previous row) of itself and/or other columns


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...