1

コスト関数を最小化する PuLP の線形問題を解こうとしています。コスト関数自体は、コスト関数の最大値の関数です。たとえば、1 日のコストがあり、1 か月のコストを最小化しようとしています。これは、1 日のコストと 1 か月の最大 1 日のコストの合計です。 . 最終的なソリューションで関数の最大値を取得しているとは思いません。この問題のトラブルシューティング方法がわかりません。コードの基本的な概要は次のとおりです。

# Initialize the problem to be solved
prob = LpProblem("monthly_cost", LpMinimize)

# The number of time steps
# price is a pre-existing array of variable prices
tmax = len(price)
# Time range
time = list(range(tmax))

# Price reduction at every time step
d = LpVariable.dict("d", (time), 0, 5)
# Price increase at every time step 
c = LpVariable.dict("c", (time), 0, 5)

# Define revenues = price increase - price reduction + initial price
revenue = ([(c[t] - d[t] + price[t]) for t in time])
# Find maximum revenue
max_revenue = max(revenue)

# Initialize the problem
prob += sum([revenue[t]*0.0245 for t in time]) + max_revenue

# Solve the problem
prob.solve()

価格 [0] が価格の最大値ではなく、c_0 と d_0 の両方が 0 であっても、変数 max_revenue は常に c_0 - d_0 + 価格 [0] に等しくなります。動的最大値が問題に挿入されていることを確認する方法を知っている人はいますか? ありがとう!

4

1 に答える 1