OpenSolver for Excel
The Open Source Optimization Solver for Excel
We welcome your comments on OpenSolver.
Dear Open Solver Team,
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.
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.
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 day, dear developers!
Thanks a lot for the great tool! I was amazed at the efficiency of solving integer programming problems for 20-30 thousand variables.
I enjoy teaching my OpenSolver students on my MBA course.
I recently came across an integer linear optimization problem that only has 161 binary variables and cannot be solved with OpenSolver (or it takes more than 12 hours to solve).
Excel file link: https://1drv.ms/u/s!ArFRI2i3V3yXl_ddltR-08_O9pumjQ?e=yfe1ze
The task schedules delivery days for 7 days of the week and 23 stores (binary variables E2: K24). I want to schedule a given number of deliveries D2: D24 for each store. The goal is to achieve a minimum difference in the loading of the central warehouse on different days of the week.
(The real problem is a little more complicated, but that’s enough.)
Surprisingly, the Calc Solver add-in (LibreOffice) solves the problem in a few minutes and gives the solution shown in the file (for example).
Can you please tell me what is the problem? The task looks very simple.
Best regards, Sergei.
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.
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
Dear OpenSolver developers:
I am a huge fan of using Excel when modelling Process Engineering simulations.
I have been using circular references, scaling and GRG, and find it quite powerful.
However, I sometimes miss a more powerful non linear solver, such as the ones you have implemented.
I have been trying to use OpenSolver, but seems to get into trouble when dealing with circular references.
May I ask you to state if this is the case? If so, are you planning on embedding OpenSolver with native circular references?
Thank you in advance.
You should add circular references as constraints. I have not tried this, but it should work. You then need to manually break the cycle yourself; the OpenSolver constraint ‘completes’ the cycle. Let us know if it works, Andrew
Error in loading DLL (Error 48)，Automation error (Error 440)
Excel will report errors when running on the computer. No loss is found in the reference, but it works normally on another computer
I am just thinking about using OpenSolver, and I would like to know if it is possible to define the problem in Excel and then save it as mps or gurobi file or in another syntax. Thank you.
Yes; if you open the working files directory (using the OpenSolver menu), then you can see the .lp file. But, don’t forget that OpenSolver can run Gurobi directly for you. Cheers, Andrew
On the webpage: https://opensolver.org/opensolver-for-google-sheets/
“You can install the OpenSolver Add-on by clicking on the Chrome Web Store link below” but I couldn’t find any such link.
“When you start OpenSolver” but the webpage does not contain a description of starting OpenSolver within Google Sheets.
OpenSolver for Google Sheets is currently unavailable because of issues with changes made by Google that we are working through. Sorry about this, Andrew
I tried every free solver and minimizer available free of cost.
This is by far my favorite because it’s simple. Personally prefer this over SolverStudio because it can do what I want with minimum programming work on my side.
-minimizing one cell calculated in a spreadsheet
-larger than 200 variables. (So standard solver couldn’t handle it.)
This works. My suggestions follow
-On installation, it seems to work better with OpenSolver extracted into the MS Excel Addin’s folder. Specifically, if one clicks: file->options(at the bottom left)->Add-Ins-> Go (after manage in the middle with excel add-ins selected)-> browse (on analysis toolpak) -> it will take you to the addins folder. Copy OpenSolver to there.
-when selecting constraints and variables sometimes it seems to mess up and write the same cells multiple times. Sheet1!$A$1:$C$8 is how it should look as shown in the examples. Where ‘Sheet1!” = sheet name. $A$1:$C$8 = rows and columns from A1 to C8.
Very grateful for this OpenSolver. Well done Andrew Mason.
Your email address will not be published. Required fields are marked *