Setting the optimum value at any given setpoint

I use open solver to solve the optimization problem. The problem is this:

Suppose I optimize input with a given general cost constraint and input availability. We have input cost and we want to minimize costs. Another limitation is that the optimized input falls into any of the given values, for example, input11, input12, input13 and input14. This discrete input range varies depending on the input.

So, we have 3 limitations:

  • budget,
  • input capacitance for each input and inputs
  • must be included in any of four possible options.

Part of the code I created:

Sub TestOpensolver()

Dim TestSheet As Worksheet
Set TestSheet = Worksheets("Optimized_Results")

    OpenSolver.ResetModel Sheet:=TestSheet

    'Objective Definition
    OpenSolver.SetObjectiveFunctionCell TestSheet.Range("AC3"), Sheet:=TestSheet
    OpenSolver.SetObjectiveSense MinimiseObjective, Sheet:=TestSheet

    'Variables Definition
    OpenSolver.SetDecisionVariables TestSheet.Range("AK3:AK8"), Sheet:=TestSheet
    OpenSolver.SetDecisionVariables TestSheet.Range("AQ3:AR8"), Sheet:=TestSheet

    ' Constraints       

    OpenSolver.AddConstraint TestSheet.Range("AK3:AK8"), RelationLE, TestSheet.Range("W3:W8"), Sheet:=TestSheet
    OpenSolver.AddConstraint TestSheet.Range("AK3:AK8"), RelationGE, TestSheet.Range("X3:X8"), Sheet:=TestSheet


    OpenSolver.AddConstraint TestSheet.Range("AS3:AS8"), RelationLE, TestSheet.Range("AT3:AT8"), Sheet:=TestSheet


    OpenSolver.RunOpenSolver , False



End Sub

Can anyone help me solve the problem?

Thank!

+4
1

'' , , :

input1 = input11*y11 + input12*y12 + input13*y13 + input14*y14
y11+y12+y13+y14 <= 1
y11,y12,y13,y14 binary variables
0

Source: https://habr.com/ru/post/1677668/


All Articles