Hi, Omkar!

It is more convenient to use the functions described on the manual page: https://docs.microsoft.com/en-us/office/vba/excel/concepts/functions/using-the-solver-vba-functions .

In this case, you get the following code.

SolverReset

SolverOK setCell:=Range(“$Z$1”), MaxMinVal:=2, byChange:=Range(“$Y$4: $Y$22”)

SolverAdd cellRef:=Range(“$Y$4: $Y$22”), relation:=4 ‘ integer variables

Ranges of cells are specified for the active sheet of the active book, but this is usually what you need.

There are examples of using functions in this reference, everything works fine.

Good luck!

]]>I am using windows 10 and tried also to place the files under …\microdoft\addins

Any advice is welcome ]]>

Sergei: This is the behaviour we expect. Proving we have the best solution is often much harder than finding the best solution. Try to change your equations to remove equivalent equally-good solutions by, for example, giving staff small random preferences (i.e. slightly lower costs) for shifts (or whatever makes sense for your problem). Setting a large optimality tolerance can also help reduce run times. Andrew

]]>Great that you are trying SolverStudio. Sorry, but there’s no shortcut for this move from OpenSolver to SolverStudio. However, you may find it useful to export the .lp file from OpenSolver, and look at this to better understand your model. Andrew

]]>Not automatically; you will need to add extra variables to let constraints be violated, eg replace x+y<=10 with x+y<=10+z, and then penalise the sum of these extra variables. Hope this helps, Andrew

]]>I am working with a 3900-4000 variable MILP that comes up with an optimal solution. When I extend the variables to say 4200 variables, I get an error that OpenSolver comes up with an infeasible solution. Is there a way to find out what constraints are making my program infeasible now that I have added a few more variables? ]]>

I am using Open Solver dialog box to build the model manually, but this a daunting task to do repetitively when I have to build and run model 6 times by changing objective, variable and constraints.

I am able to change objective and variables using VBA, but unable to add, set or update constraints using VBA code. I tried this code :

Dim TestSheet As Worksheet

Set TestSheet = Sheets(“Dispatch Planning Model”)

Application.Run “OpenSolver.xlam!OpenSolverAPI.ResetModel”, TestSheet

Application.Run “OpenSolver.xlam!OpenSolverAPI.SetObjectiveFunctionCell”, TestSheet.Range(“Z1”), TestSheet

Application.Run “OpenSolver.xlam!OpenSolverAPI.SetDecisionVariables”, TestSheet.Range(“y4:y22”), TestSheet

Application.Run “OpenSolver.xlam!OpenSolverAPI.AddConstraint”, 1, TestSheet.Range(“y4:y22”), RelationINT, TestSheet – this line of my code gets error.

Please help.

]]>Open solver seems to be the perfect tool for this task. Thank you ]]>

Good day!

I was able to figure out how to overcome the described complexity.

In my opinion, a problem occurs when a problem has a large number of equally good solutions.

Tracking the optimization process shows that the algorithm quickly achieves excellent objective function values, and then continues to look for even better options.

From the point of view of practice, it is necessary to limit the objective function to some reasonable value. For minimization, this is the lower bound.

After that, the practical problem is solved quickly enough.

Sincerely yours, Sergei.

]]>