简体   繁体   English

在Visual Basic .NET中再现Excel Solver GRG非线性优化

[英]Reproducing Excel Solver GRG Nonlinear Optimization in Visual Basic .NET

I am trying to re-produce the following Excel Solver GRG Nonlinear optimization using the Microsoft Solver Foundation in VB.NET (numbers are simplified for the sake of this example): 我正在尝试使用VB.NET中的Microsoft Solver Foundation重现以下Excel Solver GRG非线性优化(为简化示例,数字被简化):

  1. Objective : Total Gas Rate = 100000 目标 :总燃气费率= 100000
  2. Variable : Well 1 Oil Rate 变量 :1井油率
  3. Constraints : 0 <= Well 1 Gas Rate <= 1000, Well 2 Gas Rate = 2000 限制条件 :0 <= 1口气费率<= 1000,2口气费率= 2000

This optimization is subject to the following relationships: 此优化取决于以下关系:

  1. Well 1 Gas Rate = Well 1 Oil Rate * 5 1号井的天然气费率 = 1号井的石油费率* 5
  2. Total Gas Rate = Well 1 Gas Rate + Well 2 Gas Rate 总气率 = 1气井+ 2气井

Is it possible to solve such a problem using Solver Foundation? 使用Solver Foundation是否可以解决这样的问题? When trying to implement this, the two things I struggled with are: 尝试实现此目标时,我遇到的两件事是:

  1. It appears that Solver Foundation models only have two GoalKind's: minimum and maximum. 看来Solver Foundation模型只有两个GoalKind:最小值和最大值。 In my case, I am trying to optimize for a specific value. 就我而言,我正在尝试针对特定值进行优化。 Is there any way to do this? 有什么办法吗?
  2. How do I define the above relationships? 如何定义以上关系? I would think the latter would be defined as part of the goal definition (eg, model.AddGoal("total_gas_rate", GoalKind.[not sure what goes here], Well1PGasRate + Well2PGasRate ), but how do I define the other one? 我认为后者将被定义为目标定义的一部分(例如, model.AddGoal("total_gas_rate", GoalKind.[not sure what goes here], Well1PGasRate + Well2PGasRate ),但是我如何定义另一个?

Thanks! 谢谢!

This answer only addresses part 1 of your question and in a conceptual manner, but hopefully it is helpful. 该答案仅以概念性的方式解决了您问题的第1部分,但希望对您有所帮助。 If you're trying to optimize for a specific value target and the output of your function is output then you could try something like this pseudocode: 如果您要针对特定​​的值target进行优化,并且输出了函数的output则可以尝试使用以下伪代码:

minimize(absolute_value(output/target-1))

Effectively, this will give you a value that reaches zero as the output of your function nears the target value. 实际上,当函数的输出接近目标值时,这将使您的值达到零。 So you can still use an optimization engine that minimizes the final output of your function. 因此,您仍然可以使用优化引擎来最大程度地减少函数的最终输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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