优化两个变量的非线性函数(python)
我有一个目标函数:优化两个变量的非线性函数(python),python,nonlinear-optimization,Python,Nonlinear Optimization,我有一个目标函数: def calculate_output(social_sum, learning_sum, w_1, w_2): economy_output = sum(social_sum) * sum(learning_sum) - w_1 * sum(learning_sum) - w_2 *sum(social_sum) return economy_output 我需要满足两个约束,不是优化,而是满足 这两个限制是: def calculate_fz_1(
def calculate_output(social_sum, learning_sum, w_1, w_2):
economy_output = sum(social_sum) * sum(learning_sum) - w_1 * sum(learning_sum) - w_2 *sum(social_sum)
return economy_output
我需要满足两个约束,不是优化,而是满足
这两个限制是:
def calculate_fz_1(w_1, w_2):
social_sum, learning_sum = calculate_decisions(w_1, w_2, gamma_physical_social, gamma_physical_learning,
gamma_online_learning, gamma_online_social, Cost_Online,
Cost_Physical, bivariate_distribution, types_of_agents)
total_social = sum(social_sum)
total_learning = sum(learning_sum)
marginal_product_z1 = sum(social_sum) - w_1
return marginal_product_z1
以及:
这些约束必须等于零
我的问题是,用于计算边际产品的两个变量本质上是非线性和离散的(变量“社会总和”和“学习总和”实际上是由几个离散的变量决定的),因此我认为我不能使用scipy.optimize
但我在stack上听说,使用scipy可以做到这一点,这是真的吗?谢谢 贝叶斯优化可以做离散优化。也许可以尝试:变量离散的非线性优化称为MINLP(混合整数NLP)。有现成的解决方案来处理这些问题。我们还看到元启发式被用于解决此类问题。
def calculate_fz_2(w_1, w_2):
social_sum, learning_sum = calculate_decisions(w_1, w_2, gamma_physical_social, gamma_physical_learning,
gamma_online_learning, gamma_online_social, Cost_Online,
Cost_Physical, bivariate_distribution, types_of_agents)
marginal_product_z2 = sum(learning_sum) - w_2
return marginal_product_z2