Export (0) Print
Expand All
7 out of 10 rated this helpful - Rate this topic

Samples for Solver Foundation

Solver Foundation 3.0

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.

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 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 error-handling code to your projects to make them as secure and robust as you deem appropriate.

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:

  • How to bind data to parameters.

  • How to bind data to decisions.

  • How to define constraints.

LP

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

  • How to bind data to parameters.

  • How to bind data to decisions.

  • How to set a goal.

  • How to define constraints.

MIP

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

  • How to bind data to parameters.

  • How to bind data to decisions.

  • How to set a goal.

  • How to define constraints.

NLP

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

  • How to bind data to parameters.

  • How to bind data to decisions.

  • How to set a goal.

  • How to define constraints.

NLP

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

  • How to bind parameters to named ranges.

  • How to bind data to decisions.

  • How to specify initial values for decisions.

QP

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

  • How to bind data to parameters.

  • How to bind data to decisions.

  • How to set a goal.

  • How to define constraints.

SOS

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

  • How to bind data to parameters.

  • How to bind data to decisions.

  • How to set a goal.

  • How to define constraints.

Stoch

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

  • How to bind data to parameters.

  • How to bind data to random parameters.

  • How to bind data to decisions.

  • How to bind data to recourse decisions.

  • How to set a goal.

  • How to define constraints.

Sample

Description

OSDLDemo and OSDLLib

Demonstrates how to create an optimization domain-specific language in Visual F#. Specifically, this sample demonstrates:

  • How to add a data-specific language.

  • How to use F# quotations to reinterpret a new language.

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:

  • How to use the units-of-measure feature in Visual F#.

  • How to use enumerated types.

Sample

Description

GurobiSample

Demonstrates how to use the Gurobi solver and the SFS APIs.

Sample

Description

MSFForWSS

Demonstrates how to create a SharePoint 2010 Web part that loads Solver Foundation.

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:

  • How to add decisions.

  • How to load activities from an XML file.

  • How to add constraint programming directives.

  • How to configure the tree search.

CSP\CarConfigurator

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

  • How to use XAML.

  • How to create a model programmatically.

  • How to add decisions.

CSP\Color

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

  • How to use the Solver Foundation Services.

  • How to add decisions.

  • How to add constraints.

  • How to create a model programmatically.

  • How to create a report that summarizes the total number of solutions.

CSP\Nasa

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

  • How to create and load a model in OML.

  • How to solve a model.

  • How to show the solution in a report.

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:

  • How to test for feasibility.

  • How to change a model to be feasible.

  • How to generate a report.

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:

  • How to create a demand.

  • How to create a model.

  • How to add multiple decisions.

  • How to bind demands as parameters.

  • How to add constraints and goals.

  • How to solve a model and show the report.

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:

  • How to add tasks.

  • How to add decisions and parameters.

  • How to add constraints and goals.

  • How to solve a model and show the report.

MIP

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

  • How to add decisions and constraints.

  • How to add a simplex directive.

  • How to solve a model and show the report.

NLP\Logistic Regression

Demonstrates how to use the compact quasi-Newton 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:

  • How to bind data to parameters.

  • How to bind data to decisions.

  • How to set a goal.

  • How to define constraints.

QP

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

  • How to implement Markowitz portfolio optimization.

  • How to bind data.

  • How to use an interior point method directive.

  • How to use an event handler to track progress.

  • How to integrate the SFS into an application.

SOS2\Approx

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

  • How to add decisions and parameters.

  • How to bind data.

  • How to add constraints and goals.

  • How to solve a model and show the report.

SOS2\Purchase

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

  • How to add decisions and parameters.

  • How to add constraints and goals.

  • How to solve a model and show the report.

Stoch\AirlineAllocation

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

  • How to bind data to parameters.

  • How to bind data to random parameters.

  • How to bind data to decisions.

  • How to bind data to recourse decisions.

  • How to set a goal.

  • How to define constraints.

Stoch\Petrochem

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

  • How to create a model.

  • How to add decisions and recourse decisions.

  • How to add parameters.

  • How to add constraints and goals.

  • How to solve a model and show the report.

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:

  • How to create a model.

  • How to add decisions.

  • How to add parameters.

  • How to add constraints and goals.

  • How to solve a model and show the report.

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:

  • How to create a demand.

  • How to create a model.

  • How to add multiple decisions.

  • How to bind demands as parameters.

  • How to add constraints and goals.

  • How to solve a model and show the report.

F#

Sample

Description

PetroChem

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

  • How to create a model.

  • How to add decisions and recourse decisions.

  • How to add parameters.

  • How to add constraints and goals.

  • How to solve a model and show the report.

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:

  • How to create a model.

  • How to add decisions and recourse decisions.

  • How to add parameters.

  • How to add constraints and goals.

  • How to solve a model and show the report.

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:

  • How to use the Solver Foundation Services.

  • How to add decisions.

  • How to add constraints.

  • How to create a model programmatically.

  • How to create a report with total number of solutions.

Nasa

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

  • How to create and load a model in OML.

  • How to solve a model.

  • How to show the solution in a report.

Newsboy

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

  • How to add decisions to determine how many newspapers to order.

  • How to add recourse decisions to determine how many to sell or back order.

  • How to add goals and constraints.

  • How to solve a model and get the report.

ProductionModels

Demonstrates how to produce bands, coils, and plates and maximize profit.

Sudoku

Demonstrates how to create an Excel add-in to implement a Sudoku puzzle.

Zebra

Demonstrates how to use a constraint system to solve a logic puzzle.

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.

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 quasi-Newton 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:

  • How to create a model.

  • How to add decisions and recourse decisions.

  • How to add parameters.

  • How to add constraints and goals.

  • How to solve a model and show the report.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.