Samples for Solver Foundation
This section contains samples that demonstrate how to develop for Solver Foundation in Visual Studio and Microsoft Excel. The code in these samples illustrates the syntax, structure, and techniques used to build Solver Foundation solutions.
Locating Sample Files
For the most current samples, see the %USERPROFILE%\Documents\Microsoft Solver Foundation\Samples folder (Windows 7, Windows Vista, Windows Server 2008, Windows Server 2003) or the %USERPROFILE%\My Documents\Microsoft Solver Foundation\Samples folder (Windows XP).
Security Note 

Microsoft provides the included samples "AS IS" with no warranties. The code in the samples is provided just to illustrate concepts. The provided code may not meet security requirements for any specific environment. We recommend that you add security and errorhandling code to your projects to make them as secure and robust as you deem appropriate. 
Excel Samples
Sample 
Description 

CSP 
Demonstrates how to allocate computers for jobs based on hardware capabilities (dual processor, gigabit Ethernet, RAID, and so on). Specifically, this sample demonstrates:

LP 
Demonstrates how to solve a supply chain problem. Specifically, this sample demonstrates:

MIP 
Demonstrates how to allocate aircraft to different routes. Specifically, this sample demonstrates:

NLP 
Demonstrates how to optimize speed on shipping routes to minimize fuel consumption. Specifically, this sample demonstrates:

NLP 
Demonstrates how to solve a nonlinear data fitting problem using the NelderMead solver (NelderMeadSolver). Specifically, this sample demonstrates:

QP 
Demonstrates how to allocate investments between stocks, money market accounts, bonds, realty, foreign investments, and hedge funds. Specifically, this sample demonstrates:

SOS 
Demonstrates how much to buy from different suppliers. Specifically, this sample demonstrates:

Stoch 
Demonstrates how to allocate aircraft to different routes. Specifically, this sample demonstrates:

FSharp Samples
Sample 
Description 

OSDLDemo and OSDLLib 
Demonstrates how to create an optimization domainspecific language in Visual F#. Specifically, this sample demonstrates:

SfsMeasures and SfsMeasuresDemo 
Demonstrates how to wrap a subset of the Solver Foundation Services (SFS) API and use that subset to solve petrochemical problems. Specifically, this sample demonstrates:

Gurobi Samples
Sample 
Description 

GurobiSample 
Demonstrates how to use the Gurobi solver and the SFS APIs. 
SharePoint
Sample 
Description 

MSFForWSS 
Demonstrates how to create a SharePoint 2010 Web part that loads Solver Foundation. 
Solver Foundation Services Samples
ASP.NET
Sample 
Description 

CameraDepot 
Demonstrates how to create a retail store Web application to sell cameras. 
C#
Sample 
Description 

ColumnGeneration 
Demonstrates how to use constraint programming and mixed integer programming to implement a column generation algorithm. 
CSP\ActivityScheduler 
Demonstrates how to schedule the length of time for different activities at different locations. Specifically, this sample demonstrates:

CSP\CarConfigurator 
Demonstrates how to configure a car based on engine size, model, package, and price. Specifically, this sample demonstrates:

CSP\Color 
Demonstrates how to color a map of countries/regions where neighboring countries/regions are not the same color. Specifically, this sample demonstrates:

CSP\Nasa 
Demonstrates how to maximize the number of satellites. Specifically, this sample demonstrates:

CSP\Zebra 
Demonstrates how to use a constraint system to solve a logic puzzle. 
EventsAndReporting\Diet Problem 
Demonstrates how to use a linear program to minimize the cost of food while satisfying minimum nutritional standards. Specifically, this sample demonstrates:

EventsAndReporting\LpSolvePluginDemo 
Demonstrates how to use the SFS and LP solver. Then demonstrates how to use the events and reporting features. 
LP\AlloyProduction 
Demonstrates how to use linear programming to produce minimum quality steel from seven different alloys. 
LP\Chess 
Demonstrates how to use linear programming to determine how many of two different chess sets to make and maximize profit. 
LP\Knapsack 
Demonstrates how to use linear programming to select the items of greatest value without surpassing the maximum weight capacity of a knapsack. 
LP\ProductionPlanning 
Demonstrates how to use mixed integer programming to determine how many bicycles to build to satisfy forecast demand and minimize production cost. Specifically, this sample demonstrates:

LP\StadiumConstruction 
Demonstrates how to find the shortest amount of time required to complete a sequence of tasks for building a stadium. Specifically, this sample demonstrates:

MIP 
Demonstrates how to use the mixed integer linear programming solver. Specifically, this sample demonstrates:

NLP\Logistic Regression 
Demonstrates how to use the compact quasiNewton solver (CompactQuasiNewtonSolver) to perform logistic regression on a data set. 
NLP\ShippingRoute 
Demonstrates how to optimize speed on shipping routes to minimize fuel consumption. Specifically, this sample demonstrates:

QP 
Demonstrates how to maximize a stock portfolio by using quadratic programming. Specifically, this sample demonstrates:

SOS2\Approx 
Demonstrates how to use special ordered set type two (SOS2) constraints to approximate a nonlinear function. Specifically, this sample demonstrates:

SOS2\Purchase 
Demonstrates how to choose the amount of supplies to buy from three different suppliers while minimizing cost. Specifically, this sample demonstrates:

Stoch\AirlineAllocation 
Demonstrates how to allocate aircraft to different routes. Specifically, this sample demonstrates:

Stoch\Petrochem 
Demonstrates how to decide where to buy petroleum from. Specifically, this sample demonstrates:

Stoch\ProductMixture 
Demonstrates how to use stochastic programming to determine how to use carpentry and finishing workstations to make furniture and maximize profit. 
C++
Sample 
Description 

OhioBank 
Demonstrates how to complete all the work at a bank but minimize the total wages per week. 
PetroChem 
Demonstrates how to decide where to buy petroleum from. Specifically, this sample demonstrates:

ProductionPlanning 
Demonstrates how to use mixed integer programming to determine how many bicycles to build to satisfy forecast demand and minimize production cost. Specifically, this sample demonstrates:

F#
Sample 
Description 

PetroChem 
Demonstrates how to decide where to buy petroleum from. Specifically, this sample demonstrates:

IronPython
Sample 
Description 

BankShiftScheduling 
Demonstrates how to complete all the work at a bank but minimize the total wages per week. 
PetroChem 
Demonstrates how to decide where to buy petroleum from. Specifically, this sample demonstrates:

Optimization Modeling Language (OML)
Sample 
Description 

CSP 
Five OML examples to solve constraint problems. 
LP 
Five OML examples to demonstrate linear programming.. 
MIP 
Three OML examples to demonstrate mixed integer programming. 
QP 
Two OML examples to demonstrate quadratic programming. 
Stoch 
An OML example to demonstrate stochastic programming: airline allocation. 
SQL
Sample 
Description 

GenerateDataPartition 
Demonstrates how to allocate data partitions. 
SQLDataBinding 
Demonstrates how to allocate data partitions by using Solver Foundation Services. 
Visual Basic
Sample 
Description 

Color 
Demonstrates how to color a map of countries/regions where neighboring countries/regions are not the same color. Specifically, this sample demonstrates:

Nasa 
Demonstrates how to maximize the number of satellites. Specifically, this sample demonstrates:

Newsboy 
Demonstrates how to optimize newspaper inventory. Specifically, this sample demonstrates:

ProductionModels 
Demonstrates how to produce bands, coils, and plates and maximize profit. 
Sudoku 
Demonstrates how to create an Excel addin to implement a Sudoku puzzle. 
Zebra 
Demonstrates how to use a constraint system to solve a logic puzzle. 
Solver Plugins Samples
Sample 
Description 

CLP 
Demonstrates how to use the CLP solver and Solver Foundation. 
Cplex 
Demonstrates how to use the CPLEX solver and Solver Foundation. 
Lindo 
Demonstrates how to use the LINDO solver and Solver Foundation. 
LPSolve 
Demonstrates how to use the lp_solver solver and Solver Foundation. 
Mosek 
Demonstrates how to use the Mosek solver and Solver Foundation. 
XpressMP 
Demonstrates how to use the FICO Xpress solver and Solver Foundation. 
Solvers Samples
C#
Sample 
Description 

CQN 
Demonstrates how to implement and solve the Rosenbrock function. 
CSP\BusDriver 
Demonstrates how to schedule London bus drivers to complete each route once and minimize cost. 
CSP\RoundRobinMatches 
Demonstrates how to use a constraint system to schedule round robin matches. 
CSP\Zebra 
Demonstrates how to use a constraint system to solve a logic puzzle. 
LP 
Demonstrates how to manage and optimize a portfolio by using linear programming. 
MIP\CapitalBudgeting 
Demonstrates how to manage a budget. 
MIP\CuttingStock 
Demonstrates how to cut fixed width fabric and minimize the loss of wasted fabric. 
MIP\Dantzig 
Demonstrates how to implement a linear programming example by using the simplex solver, Solver Foundation Services, and optimization modeling language. 
NLP 
Demonstrates nonlinear programming by using the compact quasiNewton solver. 
QP 
Demonstrates how to manage and optimize a portfolio by using quadratic programming. 
SOCP 
Demonstrates how to implement a sum of norms minimization problem. 
IronPython
Sample 
Description 

Factor_RoundRobin 
Demonstrates how to use a constraint system to schedule round robin matches. 
PetroChem 
Demonstrates how to decide where to buy petroleum from. Specifically, this sample demonstrates:

See Also
Concepts
Getting Started (Solver Foundation)