Loading and solving an Excel workbook model in a custom application
With Solver SDK Platform, I understand it's possible to "deploy" an optimization model created in an Excel workbook, by creating a custom application in C++ or C#, and simply loading the Excel workbook into that custom application and asking it to "Solve". But how do I actually do this? Do you have an example?
[Answer]
If you download and run our SDKSetup program (and activate a trial license) to install Solver SDK Platform, you can build and run a number of examples, one of which illustrates the process of loading an Excel workbook into a custom application. These are provided in several different programming languages -- C, C++, C#, VB.NET, Java, etc.
If you're using MS Visual Studio, you would just open the "Product Mix" Visual Studio solution file for the appropriate language and Visual Studio version, then choose Build and Run. You'll see in the source code that it simply creates a Problem object, and calls Problem.Load to load the Excel workbook. At that point you can immediately call Problem.Solver.Optimize to solve the model, with the data that was in the workbook when you saved it.
More often, you'll want to update the input data before you solve. The Product Mix example illustrates how to do this. In the Excel workbook, you identify one or more ranges of cells (such as A1:B3) that you want to update at runtime, by placing a formula such as =PsiInput(A1:B3) in another cell. In the SDK application, immediately after you call Problem.Load, you can reference Problem.InputData["A1:B3"].Value[i,j] as though this were an array, and assign new numeric values to the array elements. Then you simply call Problem.Solver.Optimize to solve the model with the newly updated data.
Please sign in to leave a comment.
Comments
0 comments