<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Microsoft Solver Foundation</title><link>http://blogs.msdn.com/b/solverfoundation/</link><description>Optimization and modeling in Excel and Visual Studio</description><dc:language>en-US</dc:language><generator>Telligent Community 5.6.583.17018 (Build: 5.6.583.17018)</generator><item><title>Using Plug-in Solvers in Solver Foundation 3.1 for Excel</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2011/09/15/using-plug-in-solvers-in-solver-foundation-3-1-for-excel.aspx</link><pubDate>Thu, 15 Sep 2011 22:08:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10212064</guid><dc:creator>Nate Brixius</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10212064</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2011/09/15/using-plug-in-solvers-in-solver-foundation-3-1-for-excel.aspx#comments</comments><description>&lt;p&gt;In this post we will show you how to use third-party solvers with the Microsoft Solver Foundation Add In for Excel. We assume that you have installed the Express version of Solver Foundation 3.1 from &lt;a href="http://solverfoundation.com"&gt;solverfoundation.com&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;There are two steps in the process:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;Registering &lt;/strong&gt;the solvers you want to be able to use in Excel, &lt;/li&gt;    &lt;li&gt;Optionally &lt;strong&gt;directing&lt;/strong&gt; that a particular solver should be used to solve a model. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;   &lt;br /&gt;In this post we will show you how to register and provide directives for the Gurobi solver, since it is included in the Solver Foundation installation process. The steps are similar for other solvers.&lt;/p&gt;  &lt;p&gt;Registration is done by providing a configuration file. This process is painful (and we hope to make it easier in the future), but you only need to do it once. &lt;/p&gt;  &lt;p&gt;Configuration files are a standard mechanism for specifying information about how a .Net application should run. This configuration file has a section that describes the version of Solver Foundation that is installed (the version number for MSF 3.1 is 3.0.2.10889), and a section where plug-in solvers are listed. Here’s what you need to do:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Close Excel. &lt;/li&gt;    &lt;li&gt;Open a command shell with administrator privileges: click the Windows start button, type “cmd” in the search box, right click on the “cmd” icon and select “Run as administrator”. &lt;/li&gt;    &lt;li&gt;Go to the Solver Foundation installation directory. On many machines, this means typing “cd C:\Program Files\Microsoft Solver Foundation\3.0.2.10889\MsfForExcel” &lt;/li&gt;    &lt;li&gt;Create a new text file called MicrosoftSolverFoundationForExcel.dll.config, for example by typing “notepad MicrosoftSolverFoundationForExcel.dll.config” &lt;/li&gt;    &lt;li&gt;Paste in the following:      &lt;br /&gt;      &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;configSections&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;section&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MsfConfig&amp;quot;&lt;/span&gt; 
             &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Microsoft.SolverFoundation.Services.MsfConfigSection, Microsoft.Solver.Foundation, Version=3.0.2.10889, Culture=neutral, PublicKeyToken=31bf3856ad364e35&amp;quot;&lt;/span&gt; 
             &lt;span class="attr"&gt;allowLocation&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;allowDefinition&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Everywhere&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;allowExeDefinition&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MachineToApplication&amp;quot;&lt;/span&gt; 
             &lt;span class="attr"&gt;restartOnExternalChanges&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;requirePermission&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; 
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;configSections&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MsfConfig&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MsfPluginSolvers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MsfPluginSolver&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;gurobi&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;capability&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;LP&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;assembly&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;GurobiPlugIn.dll&amp;quot;&lt;/span&gt; 
                       &lt;span class="attr"&gt;solverclass&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;SolverFoundation.Plugin.Gurobi.GurobiSolver&amp;quot;&lt;/span&gt; 
                       &lt;span class="attr"&gt;directiveclass&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;SolverFoundation.Plugin.Gurobi.GurobiDirective&amp;quot;&lt;/span&gt; 
                       &lt;span class="attr"&gt;parameterclass&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;SolverFoundation.Plugin.Gurobi.GurobiParams&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; 
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;MsfPluginSolvers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;MsfConfig&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;Save the file and quit. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We have now registered the Gurobi solver to handle linear (LP) models. Once a solver has been registered, it is available for use in the Excel add-in for any spreadsheet. This is because the add-in reads the configuration file every time Excel boots. If you have an error in the configuration file, the add-in will report an error message. &lt;strong&gt;(If this doesn’t work, see the note at the end.)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Registered solvers are applied by default when you try to solve a model of the type specified in the config file. So, if you open up the “Supply Chain Planning” sample and click Solve, you can confirm that Gurobi was used by looking at the log:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42-metablogapi/8081.SolveLog_5F00_6414C3A0.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SolveLog" border="0" alt="SolveLog" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42-metablogapi/8004.SolveLog_5F00_thumb_5F00_0EED27B3.png" width="460" height="304" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sometimes it is useful to change solver-specific settings for better accuracy or performance. This is accomplished by adding a &lt;strong&gt;directive &lt;/strong&gt;to the model, found in the Directives tab. In Solver Foundation 3.1, registered solvers show up in the directives list alongside Solver Foundation’s built-in solvers:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42-metablogapi/3288.directives_5F00_1CBF6DAE.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="directives" border="0" alt="directives" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42-metablogapi/2211.directives_5F00_thumb_5F00_438D83EE.png" width="400" height="337" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Selecting the GurobiDirective item adds a directive to the model. In the lower portion of the modeling pane you can change any of the solver-specific settings you like. Each solver offers its own settings. For example, GurobiDirective has a Presolve property that controls which types of preprocessing rules are applied to a model before it is solved. Here we are changing the default setting to “None”:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42-metablogapi/2234.NoPresolve_5F00_3C6E4776.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="NoPresolve" border="0" alt="NoPresolve" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42-metablogapi/1541.NoPresolve_5F00_thumb_5F00_0761B846.png" width="479" height="333" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(In Solver Foundation 3.1 when you save a model, third party directive options are not retained. This limitation exists because not all third party directives support saving their information to files. In future releases we hope to include this capability.)&lt;/p&gt;

&lt;p&gt;It is possible to add more than one directive to a model. In this case, Solver Foundation will launch both solvers, effectively “racing” them against each other!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important note for Visual Studio 2010 SP1 Users:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you tried the preceding steps and no plug-in solvers appear to have been registered, and you did not encounter any error messages, you may have encountered an &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/653444/visual-studio-sp1-or-specifically-vsto-sp1-issue-with-config-file-location"&gt;unfortunate breaking change&lt;/a&gt; due to Visual Studio Tools for Office (VSTO) 4.0 SP1. Here are the steps you need to take to get back on the right track:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Run Registry Editor (Start, type in “regedit”, hit Enter) &lt;/li&gt;

  &lt;li&gt;Navigate to HKEY_CURRENT_USER\Software\Microsoft\Office\ 
    &lt;br /&gt;Excel\Addins\MicrosoftSolverFoundationForExcel\Manifest. 

    &lt;br /&gt;

    &lt;br /&gt;You should see something like the following in the right pane: 

    &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42-metablogapi/6740.image_5F00_1BE707C4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42-metablogapi/1641.image_5F00_thumb_5F00_7BCBFB06.png" width="746" height="119" /&gt;&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;Double-click on Manifest and add “file:///” to the start of the text. &lt;/li&gt;

  &lt;li&gt;Click OK, and quit Registry Editor. &lt;/li&gt;

  &lt;li&gt;Restart Excel. &lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10212064" width="1" height="1"&gt;</description></item><item><title>How to register a third-party solver in Iron Python</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2011/09/14/how-to-register-a-third-party-solver-in-iron-python.aspx</link><pubDate>Wed, 14 Sep 2011 21:31:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10211243</guid><dc:creator>Nate Brixius</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10211243</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2011/09/14/how-to-register-a-third-party-solver-in-iron-python.aspx#comments</comments><description>&lt;p&gt;For years, Solver Foundation has provided the ability to plug-in third party solvers so that they can be used using the same programming model as Solver Foundation&amp;rsquo;s built-in solvers. In the past, solvers were registered using configuration files, as we have described in &lt;a href="http://blogs.msdn.com/b/solverfoundation/archive/2011/06/17/gurobi-4-5-connector-for-solver-foundation-3-0.aspx"&gt;previous&lt;/a&gt; &lt;a href="http://blogs.msdn.com/b/solverfoundation/archive/2010/05/05/using-excel-with-a-custom-sfs-solver.aspx"&gt;blog&lt;/a&gt; &lt;a href="http://blogs.msdn.com/b/solverfoundation/archive/2011/04/27/mosek-connector-updated.aspx"&gt;posts&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Solver Foundation 3.1 provides new programming interfaces so that solvers can be registered in code at runtime. This is useful in a number of different scenarios, including in cases where configuration files are hard to specify, as in Iron Python.&lt;/p&gt;
&lt;p&gt;The following Iron Python sample code registers the Gurobi solver to handle linear (LP) models. Other solvers are registered in a similar fashion. You should be able to adapt this code to other .Net languages even if you are not familiar with Iron Python: the RegisteredSolvers.Add line is key. (The MSDN documentation for this new method will go live soon.)&lt;/p&gt;
&lt;pre class="csharpcode"&gt;import clr
&lt;span class="rem"&gt;## Bring in Solver Foundation&lt;/span&gt;
clr.AddReference(&lt;span class="str"&gt;"Microsoft.Solver.Foundation"&lt;/span&gt;)
from Microsoft.SolverFoundation.Services import *

&lt;span class="rem"&gt;## Some helper functions for Solver Foundation.&lt;/span&gt;
def const(i):
    &lt;span class="kwrd"&gt;return&lt;/span&gt; Term.op_Implicit(i)
def lessequal(term, i):
    &lt;span class="kwrd"&gt;return&lt;/span&gt; Model.LessEqual(term, const(i))

c = SolverContext()

&lt;span class="rem"&gt;## Let's add a plug-in solver.&lt;/span&gt;
c.RegisteredSolvers.Add(SolverRegistration(&lt;span class="str"&gt;"gurobi"&lt;/span&gt;, &lt;span class="rem"&gt;## name of the entry (your choice)&lt;/span&gt;
  SolverCapability.LP, &lt;span class="rem"&gt;## type of model&lt;/span&gt;
  &lt;span class="str"&gt;"Microsoft.SolverFoundation.Services.ILinearSolver"&lt;/span&gt;, &lt;span class="rem"&gt;## the interface&lt;/span&gt;
  &lt;span class="str"&gt;"GurobiPlugIn.dll"&lt;/span&gt;, &lt;span class="rem"&gt;## plugin dll &lt;/span&gt;
  &lt;span class="str"&gt;"SolverFoundation.Plugin.Gurobi.GurobiSolver"&lt;/span&gt;, &lt;span class="rem"&gt;## the solver class&lt;/span&gt;
  &lt;span class="str"&gt;"SolverFoundation.Plugin.Gurobi.GurobiDirective"&lt;/span&gt;, &lt;span class="rem"&gt;## the directive class&lt;/span&gt;
  &lt;span class="str"&gt;"SolverFoundation.Plugin.Gurobi.GurobiParams"&lt;/span&gt;)) &lt;span class="rem"&gt;## solver parameters class&lt;/span&gt;

m = c.CreateModel()
x = Decision(Domain.RealNonnegative, &lt;span class="str"&gt;"x"&lt;/span&gt;)
y = Decision(Domain.RealNonnegative, &lt;span class="str"&gt;"y"&lt;/span&gt;)
m.AddDecisions(x, y)
m.AddConstraint(&lt;span class="str"&gt;"c1"&lt;/span&gt;, lessequal(x + y, const(5)))
m.AddConstraint(&lt;span class="str"&gt;"c2"&lt;/span&gt;, lessequal(const(2) * x + y, const(7)))
m.AddGoal(&lt;span class="str"&gt;"g"&lt;/span&gt;, GoalKind.Maximize, x + y)
s = c.Solve()
print s.GetReport()&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10211243" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/tutorials/">tutorials</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/solver+connectors/">solver connectors</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/gurobi/">gurobi</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Iron+Python/">Iron Python</category></item><item><title>Microsoft Solver Foundation v3.1 Released</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2011/09/12/microsoft-solver-foundation-v3-1-released.aspx</link><pubDate>Mon, 12 Sep 2011 20:08:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10209578</guid><dc:creator>Nate Brixius</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10209578</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2011/09/12/microsoft-solver-foundation-v3-1-released.aspx#comments</comments><description>&lt;p&gt;Microsoft Solver Foundation 3.1 is now ready for download. Solver Foundation provides a complete system for optimization model specification, connection to data sources, and access to best-of-breed solvers for Excel users and .Net programmers. The Express version is available on the Solver Foundation site &lt;a href="http://msdn.microsoft.com/en-us/devlabs/hh145003.aspx"&gt;&lt;strong&gt;[click here]&lt;/strong&gt;&lt;/a&gt;, the MSDN and MSDNAA versions will be available soon, and the Enterprise version is available for purchase through &lt;a href="http://www.gurobi.com"&gt;Gurobi Optimization&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here is a partial list of new features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;New Solver Foundation Services APIs enable specification of large models with &lt;b&gt;easier to use, faster data binding using LINQ&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Improved SFS performance.&lt;/b&gt; Big models are processed in less time using less memory.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;A new nonlinear solver&lt;/b&gt; based on the Nelder-Mead method, comparable to methods provided in other environments.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Improvements to the hybrid local search&lt;/b&gt; solver to support arbitrary goals and constraints.&lt;/li&gt;
&lt;li&gt;Numerous improvements to the &lt;b&gt;Solver Foundation add-in for Excel&lt;/b&gt;:
&lt;ul&gt;
&lt;li&gt;Full support for commercial and open source solvers.&lt;/li&gt;
&lt;li&gt;Sparse parameter support.&lt;/li&gt;
&lt;li&gt;Warm start capabilities for performance and accuracy.&lt;/li&gt;
&lt;li&gt;Better support for named ranges.&lt;/li&gt;
&lt;li&gt;Complete control over all solver options &amp;ndash; including third-party solvers.&lt;/li&gt;
&lt;li&gt;Better control over logging and output.&lt;/li&gt;
&lt;li&gt;Faster data binding.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Solver Foundation Services improvements&lt;/b&gt;:
&lt;ul&gt;
&lt;li&gt;Inline Set definition.&lt;/li&gt;
&lt;li&gt;New SetBinding overloads.&lt;/li&gt;
&lt;li&gt;Support for multiple SolverContexts.&lt;/li&gt;
&lt;li&gt;Better WCF and Windows service support.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Logistic regression sample&lt;/b&gt; using the L-BFGS solver.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;Solver Foundation also includes the Gurobi 4.5 solver, providing better MIP and MIQP performance. The Standard and Enterprise versions of this release are now permitted to be used in virtualized environments including Windows Azure.&lt;/p&gt;
&lt;p&gt;Many of these improvements are based on feedback from the Solver Foundation community. &lt;a href="http://msdn.microsoft.com/en-us/devlabs/hh145003.aspx"&gt;Download the Express version&lt;/a&gt; and let us know what you think on the &lt;a href="http://social.msdn.microsoft.com/Forums/en-us/solverfoundation/threads" target="_blank"&gt;Solver Foundation forum&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;- The Solver Foundation Team&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10209578" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category></item><item><title>Microsoft Solver Foundation 3.1: preview</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2011/08/28/microsoft-solver-foundation-3-1-preview.aspx</link><pubDate>Sun, 28 Aug 2011 21:54:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10201364</guid><dc:creator>Nate Brixius</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10201364</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2011/08/28/microsoft-solver-foundation-3-1-preview.aspx#comments</comments><description>&lt;p&gt;The next release of Solver Foundation, Microsoft Solver Foundation 3.1, will be released next month. The feature set for 3.1 is the result of feedback from numerous partners and customers. This post summarizes some of the improvements.&lt;/p&gt;
&lt;h2&gt;Improved Nonlinear Programming&lt;/h2&gt;
&lt;p&gt;Microsoft Solver Foundation 3.1 provides a new &lt;strong&gt;NelderMeadSolver&lt;/strong&gt; class to support nonlinear programming. NelderMeadSolver is suitable for unconstrained or variable-constrained models, and is capable of handling nonconvex or nondifferentiable goals. NelderMeadSolver is the new default nonlinear programming solver for Microsoft Solver Foundation. Microsoft Solver Foundation 3.1 also provides improvements to the hybrid local search solver. Using the HybridLocalSearchModel.CreateNaryFunction you can build models using &lt;strong&gt;user-defined functions that contain arbitrary calculations&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;SFS and OML Modeling Improvements&lt;/h2&gt;
&lt;p&gt;Solver Foundation Services (SFS) provides several new methods to make it easier to build large parameterized models. The Set class includes a &lt;strong&gt;SetBinding&lt;/strong&gt; method to make it easier to create sets based on external data. &lt;strong&gt;New overloads for SetBinding&lt;/strong&gt; provide better performance and flexibility. The OML modeling language has been extended to support &lt;strong&gt;inline Set&lt;/strong&gt; definition.&lt;/p&gt;
&lt;h2&gt;Performance Improvements&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Numerous SFS performance improvements&lt;/strong&gt; have been made to reduce the amount of time and memory consumed, particularly for large and sparse models.&lt;/p&gt;
&lt;h2&gt;Excel Add-In Improvements&lt;/h2&gt;
&lt;p&gt;The Excel add-in for Solver Foundation 3.1 includes several new features. The directives tab now &lt;strong&gt;supports third-party solvers&lt;/strong&gt;. You can configure third-party solvers the same way as Solver Foundation&amp;rsquo;s built-in solvers. You can provide &lt;strong&gt;initial values&lt;/strong&gt; for decisions, improving performance for solvers with &lt;strong&gt;warm start&lt;/strong&gt; capabilities. The Excel add-in now provides &lt;strong&gt;sparse parameter support&lt;/strong&gt;. Previously, values needed to be specified for all possible indexes. This change means that you only need to specify nonzero values. Finally, support for binding to &lt;strong&gt;named ranges&lt;/strong&gt; in Excel has been extended. Finally, the Excel add-in provides more control over what is displayed during a solve operation through the &lt;strong&gt;new options dialog&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;Gurobi 4.5 Support&lt;/h2&gt;
&lt;p&gt;Solver Foundation 3.1 includes the &lt;strong&gt;Gurobi 4.5&lt;/strong&gt; solver. Gurobi 4.5 is the default mixed integer programming (MIP) and mixed integer quadratic programming (MIQP) solver.&lt;/p&gt;
&lt;h2&gt;Additional Samples&lt;/h2&gt;
&lt;p&gt;Solver Foundation 3.1 provides additional samples, including a &lt;strong&gt;logistic regression&lt;/strong&gt; solver based on the CompactQuasiNewtonSolver class.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10201364" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/SFS/">SFS</category></item><item><title>Gurobi 4.5 Connector for Solver Foundation 3.0</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2011/06/17/gurobi-4-5-connector-for-solver-foundation-3-0.aspx</link><pubDate>Fri, 17 Jun 2011 16:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10176339</guid><dc:creator>Nate Brixius</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10176339</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2011/06/17/gurobi-4-5-connector-for-solver-foundation-3-0.aspx#comments</comments><description>&lt;p&gt;The Gurobi connector for Solver Foundation has been updated for Gurobi 4.5. You can obtain the connector by visiting &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/solverfoundation/thread/4187ad5b-1309-4ae7-ac47-7b170364c559"&gt;the Solver Foundation forum&lt;/a&gt;. Here are installation and usage instructions for the connector. These instructions have been verified on 32- and 64-bit versions of Windows 7 using Visual Studio 2010.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Download the zip file &lt;strong&gt;Gurobi 4.5.zip&lt;/strong&gt;. It contains:&lt;/li&gt;
&lt;ol&gt;
&lt;li&gt;The &lt;strong&gt;GurobiPlugin.dll&lt;/strong&gt; which connects the Gurobi 4.5 solver to Solver Foundation 3.0.&lt;/li&gt;
&lt;li&gt;32- and 64-bit versions of the Gurobi 4.5 solver, found in the win32 and win64 directories.&lt;/li&gt;
&lt;li&gt;An updated version of the Gurobi Solver Programming Primer.&lt;/li&gt;
&lt;/ol&gt;
&lt;li&gt;Extract the zip file to a folder of your choice.&lt;/li&gt;
&lt;li&gt;Copy &lt;strong&gt;GurobiPlugin.xml&lt;/strong&gt; and &lt;strong&gt;GurobiPlugin.dll&lt;/strong&gt; into Program Files\Microsoft Solver Foundation\3.0.1.10599\Plugins (or "Plugins (x86)" for 32-bit systems). You may need administrator privileges to perform this action. If you do not know whether your system is 32- or 64-bit, from the Start menu, right click on "Computer" and select "Properties":&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42/3010.properties.png"&gt;&lt;img border="0" alt="" src="http://blogs.msdn.com/resized-image.ashx/__size/370x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42/3010.properties.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;4. Select &lt;strong&gt;gurobi45.dll&lt;/strong&gt; from the win32 or win64 folder and copy to the same folder. [&lt;strong&gt;corrected 7/28/2011&lt;/strong&gt;]&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Applications that use Solver Foundation and Gurobi need to be able to access the Solver Foundation assembly, the Gurobi plug-in assembly, and the Gurobi solver. The Solver Foundation assembly is accessed by adding a project reference in Visual Studio. To use Gurobi 4.5 in a Solver Foundation application built from Visual Studio 2010, perform the following additional steps.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the project file associated with your application in Visual Studio.&lt;/li&gt;
&lt;li&gt;Add a project reference to GurobiPlugin.dll by browsing to the destination folder in Installation Step 3.&lt;/li&gt;
&lt;li&gt;Change the configuration file for your application. For example, to make Gurobi the default LP solver for Solver Foundation 3.0, change the app.config file for your project to the following:&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp; &amp;lt;configSections&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;section name="MsfConfig"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type="Microsoft.SolverFoundation.Services.MsfConfigSection, Microsoft.Solver.Foundation, Version=3.0.1.10599, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; allowLocation="true"&lt;/span&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt; allowDefinition="Everywhere"&lt;/span&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt; allowExeDefinition="MachineToApplication"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; restartOnExternalChanges="true"&lt;/span&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt; requirePermission="true" /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp; &amp;lt;/configSections&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp; &amp;lt;MsfConfig&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MsfPluginSolvers&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MsfPluginSolver name="gurobi"&lt;/span&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt; capability="LP"&lt;/span&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt; assembly="GurobiPlugIn.dll"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; solverclass="SolverFoundation.Plugin.Gurobi.GurobiSolver"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; directiveclass="SolverFoundation.Plugin.Gurobi.GurobiDirective"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parameterclass="SolverFoundation.Plugin.Gurobi.GurobiParams" /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MsfPluginSolvers&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;nbsp; &amp;lt;/MsfConfig&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; font-size: xx-small;"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;4. Ensure that the Platform Target for your application is set to Any CPU. This can be verified by right clicking on the project in the Solution Explorer, selecting "Properties", and navigating to the Build tab:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42/5141.anycpu.png"&gt;&lt;img border="0" alt="" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-36-42/5141.anycpu.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;5. Build the application.&lt;/p&gt;
&lt;p&gt;6. Copy &lt;strong&gt;gurobi45.dll&lt;/strong&gt; from the destination folder in Installation Step 3 to the output directory for your application. This is typically found under bin\Debug. Copying gurobi45.dll to this location allows the connector to call the solver.&lt;/p&gt;
&lt;p&gt;Your application should now be configured to use Gurobi 4.5 with Solver Foundation 3.0. Consult the &lt;strong&gt;Gurobi Solver Programming Primer&lt;/strong&gt; for additional information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10176339" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/solver+connectors/">solver connectors</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/gurobi/">gurobi</category></item><item><title>MOSEK connector updated</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2011/04/27/mosek-connector-updated.aspx</link><pubDate>Wed, 27 Apr 2011 14:39:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10158634</guid><dc:creator>Nate Brixius</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10158634</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2011/04/27/mosek-connector-updated.aspx#comments</comments><description>&lt;p&gt;We are pleased to announce an updated Solver Foundation connector to the popular &lt;a target="_blank" href="http://mosek.com"&gt;MOSEK&lt;/a&gt; solver. MOSEK is designed to solve large-scale linear, mixed integer, and certain types of nonlinear models.&lt;/p&gt;
&lt;p&gt;To get started, download the free connector at the &lt;a target="_blank" href="http://social.msdn.microsoft.com/Forums/en-us/solverfoundation/threads"&gt;Solver Foundation forum&lt;/a&gt;, and install MOSEK by visiting &lt;a href="http://www.mosek.com"&gt;mosek.com&lt;/a&gt;. The connector supports Microsoft Solver Foundation version 3.0 and MOSEK version 6.0.0.103 and later. To set MOSEK as the default solver, change the configuration file for your dll or application. (&lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ff524508(v=VS.93).aspx"&gt;More information is available here&lt;/a&gt;.)&lt;/p&gt;
&lt;pre class="csharpcode"&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MsfConfig&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MsfPluginSolvers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MsfPluginSolver&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="mosek"&lt;/span&gt;
        &lt;span class="attr"&gt;capability&lt;/span&gt;&lt;span class="kwrd"&gt;="LP"&lt;/span&gt;
        &lt;span class="attr"&gt;assembly&lt;/span&gt;&lt;span class="kwrd"&gt;="MosekMsfPlugin.dll"&lt;/span&gt;
        &lt;span class="attr"&gt;solverclass&lt;/span&gt;&lt;span class="kwrd"&gt;="SolverFoundation.Plugin.Mosek.MosekInteriorPointSolver"&lt;/span&gt;
        &lt;span class="attr"&gt;directiveclass&lt;/span&gt;&lt;span class="kwrd"&gt;="SolverFoundation.Plugin.Mosek.MosekInteriorPointMethodDirective"&lt;/span&gt;
        &lt;span class="attr"&gt;parameterclass&lt;/span&gt;&lt;span class="kwrd"&gt;="SolverFoundation.Plugin.Mosek.MosekInteriorPointSolverParams"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MsfPluginSolver&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="mosek"&lt;/span&gt;
        &lt;span class="attr"&gt;capability&lt;/span&gt;&lt;span class="kwrd"&gt;="MILP"&lt;/span&gt;
        &lt;span class="attr"&gt;assembly&lt;/span&gt;&lt;span class="kwrd"&gt;="MosekMsfPlugin.dll"&lt;/span&gt;
        &lt;span class="attr"&gt;solverclass&lt;/span&gt;&lt;span class="kwrd"&gt;="SolverFoundation.Plugin.Mosek.MosekMipSolver"&lt;/span&gt;
        &lt;span class="attr"&gt;directiveclass&lt;/span&gt;&lt;span class="kwrd"&gt;="SolverFoundation.Plugin.Mosek.MosekMipDirective"&lt;/span&gt;
        &lt;span class="attr"&gt;parameterclass&lt;/span&gt;&lt;span class="kwrd"&gt;="SolverFoundation.Plugin.Mosek.MosekMipSolverParams"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MsfPluginSolver&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="mosek"&lt;/span&gt;
        &lt;span class="attr"&gt;capability&lt;/span&gt;&lt;span class="kwrd"&gt;="QP"&lt;/span&gt;
        &lt;span class="attr"&gt;assembly&lt;/span&gt;&lt;span class="kwrd"&gt;="MosekMsfPlugin.dll"&lt;/span&gt;
        &lt;span class="attr"&gt;solverclass&lt;/span&gt;&lt;span class="kwrd"&gt;="SolverFoundation.Plugin.Mosek.MosekInteriorPointSolver"&lt;/span&gt;
        &lt;span class="attr"&gt;directiveclass&lt;/span&gt;&lt;span class="kwrd"&gt;="SolverFoundation.Plugin.Mosek.MosekInteriorPointMethodDirective"&lt;/span&gt;
        &lt;span class="attr"&gt;parameterclass&lt;/span&gt;&lt;span class="kwrd"&gt;="SolverFoundation.Plugin.Mosek.MosekInteriorPointSolverParams"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;MsfPluginSolvers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;MsfConfig&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;

&lt;/p&gt;
&lt;p&gt;This connector has been designed to work with future releases of MOSEK and Solver Foundation by changing the configuration file. For example, if you have the newly released 6.0.0.106 version, add the following section to the &amp;lt;configuration&amp;gt; block:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;runtime&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;assemblyBinding&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="urn:schemas-microsoft-com:asm.v1"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;dependentAssembly&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;assemblyIdentity&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="mosekdotnet"&lt;/span&gt;
          &lt;span class="attr"&gt;publicKeyToken&lt;/span&gt;&lt;span class="kwrd"&gt;="510c00a7f38678b3"&lt;/span&gt;
          &lt;span class="attr"&gt;culture&lt;/span&gt;&lt;span class="kwrd"&gt;="neutral"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;&amp;lt;!-- Assembly versions can be redirected in application, &lt;/span&gt;
&lt;span class="rem"&gt;          publisher policy, or machine configuration files. --&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;bindingRedirect&lt;/span&gt; &lt;span class="attr"&gt;oldVersion&lt;/span&gt;&lt;span class="kwrd"&gt;="6.0.0.103"&lt;/span&gt; &lt;span class="attr"&gt;newVersion&lt;/span&gt;&lt;span class="kwrd"&gt;="6.0.0.106"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;dependentAssembly&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;assemblyBinding&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;runtime&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;This tells Solver Foundation that it is okay to use the newer version of MOSEK.&lt;/p&gt;
&lt;p&gt;Download the free connector at the &lt;a target="_blank" href="http://social.msdn.microsoft.com/Forums/en-us/solverfoundation/threads"&gt;Solver Foundation forum&lt;/a&gt;, and visit &lt;a target="_blank" href="http://mosek.com"&gt;mosek.com&lt;/a&gt; for information on evaluating or purchasing MOSEK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10158634" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/MOSEK/">MOSEK</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/solver+connectors/">solver connectors</category></item><item><title>New Solver Foundation forum and home page</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2011/04/26/new-solver-foundation-forum-and-home-page.aspx</link><pubDate>Tue, 26 Apr 2011 18:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10158288</guid><dc:creator>solverfoundation</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10158288</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2011/04/26/new-solver-foundation-forum-and-home-page.aspx#comments</comments><description>&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a target="_blank" href="http://blogs.msdn.com/b/somasegar/archive/2011/04/26/solver-foundation-on-devlabs.aspx"&gt;Soma announced on his blog today&lt;/a&gt; that there's a &lt;a target="_blank" href="http://social.msdn.microsoft.com/Forums/en-US/solverfoundation/threads"&gt;brand new MSDN forum&lt;/a&gt; and &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/devlabs/hh145003.aspx"&gt;DevLabs home page&lt;/a&gt; for Solver Foundation. The new MSDN forum is a great place to ask questions, share examples, and provide feedback to the team. Visit the MSDN forum at&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/solverfoundation/threads"&gt;&lt;span style="font-family: Calibri; color: #0000ff; font-size: small;"&gt;http://social.msdn.microsoft.com/Forums/en-US/solverfoundation/threads&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Solver Foundation has also been added to the TC Labs page. You can learn more about Microsoft Technical Computing from the TC Labs home page, or from &lt;a target="_blank" href="http://modelingtheworld.com"&gt;modelingtheworld.com&lt;/a&gt;. The Solver Foundation homepage on TC Labs is the place to start if you want to learn more about Solver Foundation. Visit the new home page at&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div class="MsoNormal"&gt;&lt;a href="http://msdn.microsoft.com/en-us/devlabs/hh145003.aspx"&gt;&lt;span style="font-family: Calibri; color: #0000ff; font-size: small;"&gt;http://msdn.microsoft.com/en-us/devlabs/hh145003.aspx&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;- Solver Foundation Team&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10158288" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Technical+Computing/">Technical Computing</category></item><item><title>New Solver Foundation Forum coming soon</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2011/04/22/new-solver-foundation-forum-coming-soon.aspx</link><pubDate>Fri, 22 Apr 2011 15:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10157116</guid><dc:creator>solverfoundation</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10157116</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2011/04/22/new-solver-foundation-forum-coming-soon.aspx#comments</comments><description>&lt;p&gt;As announced on the&amp;nbsp;&lt;a href="http://archive.msdn.microsoft.com/solverfoundation/Thread/View.aspx?ThreadId=4694"&gt;Solver Foundation&amp;nbsp;MSDN forum&lt;/a&gt;,&amp;nbsp;over the next few days we'll be rolling out brand-new Solver Foundation sites:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A brand new forum for questions and discussions. It has better search, code formatting, and more.&lt;/li&gt;
&lt;li&gt;A new download site (coming soon).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We'll post more information on both sites once they're both live. Thanks for your continued support of Solver Foundation!&lt;br /&gt;- Solver Foundation Team&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10157116" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category></item><item><title>Video: Modeling with Solver Foundation 3.0</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2011/03/22/video-modeling-with-solver-foundation-3-0.aspx</link><pubDate>Tue, 22 Mar 2011 22:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10144559</guid><dc:creator>solverfoundation</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10144559</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2011/03/22/video-modeling-with-solver-foundation-3-0.aspx#comments</comments><description>&lt;p&gt;We've posted a new video that shows how to use the Excel add-in for Solver Foundation 3.0. If you are new to modeling, optimization, or Solver Foundation, we hope you'll find this video useful as you get started.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;
&lt;object height="288" type="application/x-silverlight-2" width="512" data="data:application/x-oleobject;base64,QfXq3+HzJEysrJnDBxUISgAJAADqNAAAxB0AAAAAAAAAAAAAAAAAAAAAAABoAAAAaAB0AHQAcAA6AC8ALwBjAGgAYQBuAG4AZQBsADkALgBtAHMAZABuAC4AYwBvAG0ALwBzAGMAcgBpAHAAdABzAC8AQwBoAGEAbgBuAGUAbAA5AC4AeABhAHAAPwB2AD0AMQAuADUAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsgIAAG0AZQBkAGkAYQB1AHIAbAA9AGgAdAB0AHAAOgAvAC8AZgBpAGwAZQBzAC4AYwBoADkALgBtAHMALwBjAGgAOQAvADcAYQBiAGUALwA5ADgANgA2ADQAOQBhAGYALQA5ADQAZQAxAC0ANABmADYAYQAtAGIAOAA3AGIALQA5AGUAYQBkADAAMQA2AGIANwBhAGIAZQAvAE0AbwBkAGUAbABpAG4AZwB3AGkAdABoAE0AaQBjAHIAbwBzAG8AZgB0AFMAbwBsAHYAZQByAEYAbwB1AG4AZABhAHQAaQBvAG4AMwAwAC4AaQBzAG0ALwBtAGEAbgBpAGYAZQBzAHQALAB0AGgAdQBtAGIAbgBhAGkAbAA9AGgAdAB0AHAAOgAvAC8AbQBlAGQAaQBhAC4AYwBoADkALgBtAHMALwBjAGgAOQAvADcAYQBiAGUALwA5ADgANgA2ADQAOQBhAGYALQA5ADQAZQAxAC0ANABmADYAYQAtAGIAOAA3AGIALQA5AGUAYQBkADAAMQA2AGIANwBhAGIAZQAvAE0AbwBkAGUAbABpAG4AZwB3AGkAdABoAE0AaQBjAHIAbwBzAG8AZgB0AFMAbwBsAHYAZQByAEYAbwB1AG4AZABhAHQAaQBvAG4AMwAwAF8ANQAxADIAXwBjAGgAOQAuAGoAcABnACwAZABlAGwAaQB2AGUAcgB5AG0AZQB0AGgAbwBkAD0AYQBkAGEAcAB0AGkAdgBlAHMAdAByAGUAYQBtAGkAbgBnACwAYQB1AHQAbwBwAGwAYQB5AD0AZgBhAGwAcwBlACwAZQBuAHQAcgB5AGkAZAA9ADkAOAA2ADYANAA5AGEAZgA5ADQAZQAxADQAZgA2AGEAYgA4ADcAYgA5AGUAYQBkADAAMQA2AGIANwBhAGIAZQAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAYAAAANAAuADAALgA1ADAANAAwADEALgAwAAAAAAAAAAAAAAAAAAAAAAAAAA=="&gt;
&lt;param value="4.0.50401.0" name="minRuntimeVersion" /&gt;
&lt;param value="http://channel9.msdn.com/scripts/Channel9.xap?v=1.5" name="source" /&gt;
&lt;param value="mediaurl=http://files.ch9.ms/ch9/7abe/986649af-94e1-4f6a-b87b-9ead016b7abe/ModelingwithMicrosoftSolverFoundation30.ism/manifest,thumbnail=http://media.ch9.ms/ch9/7abe/986649af-94e1-4f6a-b87b-9ead016b7abe/ModelingwithMicrosoftSolverFoundation30_512_ch9.jpg,deliverymethod=adaptivestreaming,autoplay=false,entryid=986649af94e14f6ab87b9ead016b7abe" name="initParams" /&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;For more, check out &lt;a href="http://channel9.msdn.com/posts/Modeling-with-Solver-Foundation-30"&gt;this post on Channel 9&lt;/a&gt;. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10144559" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/tutorials/">tutorials</category></item><item><title>Sparse Parameters in Solver Foundation 3.0</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2011/01/25/sparse-parameters-in-solver-foundation-3-0.aspx</link><pubDate>Tue, 25 Jan 2011 16:44:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10120082</guid><dc:creator>Nate Brixius</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10120082</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2011/01/25/sparse-parameters-in-solver-foundation-3-0.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.solverfoundation.services.parameter(VS.93).aspx"&gt;Parameters&lt;/a&gt; represent input data for a model. Parameters are most useful when they are associated with Sets. Associating Sets with Parameters allows you define tables (or if you like: vectors&amp;nbsp; and matrices) of data: these are called "indexed parameters". When you use indexed parameters, data can change without having to update the model. A simple example is as follows:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;        Set colors = &lt;span class="kwrd"&gt;new&lt;/span&gt; Set(Domain.Any, &lt;span class="str"&gt;"colors"&lt;/span&gt;);
        Parameter codes = &lt;span class="kwrd"&gt;new&lt;/span&gt; Parameter(Domain.IntegerRange(0, 2), &lt;span class="str"&gt;"codes"&lt;/span&gt;, colors);
        Tuple&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;[] codeData = { Tuple.Create(&lt;span class="str"&gt;"red"&lt;/span&gt;, 0), Tuple.Create(&lt;span class="str"&gt;"green"&lt;/span&gt;, 1),Tuple.Create(&lt;span class="str"&gt;"blue"&lt;/span&gt;, 2) };
        codes.SetBinding(codeData, &lt;span class="str"&gt;"Item2"&lt;/span&gt;, &lt;span class="str"&gt;"Item1"&lt;/span&gt;);&lt;/pre&gt;
&lt;p&gt;We create a set, pass the set to the Parameter constructor to create an indexed decision with 0-1 entries. The values of a parameter are established through data binding using the &lt;a href="http://msdn.microsoft.com/en-us/library/ff526687(VS.93).aspx"&gt;SetBinding&lt;/a&gt; method shown above. Prior to Solver Foundation 3.0 it was necessary to specify parameter values for all the possible elements of each set used in the parameter. Let&amp;rsquo;s extend our example to define another Parameter using the same Set.&lt;/p&gt;
&lt;pre class="csharpcode"&gt;        Parameter tasteful = &lt;span class="kwrd"&gt;new&lt;/span&gt; Parameter(Domain.IntegerRange(0, 1), &lt;span class="str"&gt;"tasteful"&lt;/span&gt;, colors);
        Tuple&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;[] tasteData = { Tuple.Create(&lt;span class="str"&gt;"red"&lt;/span&gt;, 1), Tuple.Create(&lt;span class="str"&gt;"blue"&lt;/span&gt;, 1) };
        tasteful.SetBinding(codeData, &lt;span class="str"&gt;"Item2"&lt;/span&gt;, &lt;span class="str"&gt;"Item1"&lt;/span&gt;); &lt;span class="rem"&gt;// error when we call Solve&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;

&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;No value was given for "green", so an error will occur when&amp;nbsp; we try to solve a model involving the parameter.&lt;/p&gt;
&lt;p&gt;Solver Foundation 3.0 introduced the concept of &lt;strong&gt;sparse parameters&lt;/strong&gt;. This simply means that parameters can be given default values. The parameter takes on the default value for any index combinations not specified in the SetBinding statement. If we modify the previous example the value tasteful[&amp;ldquo;green&amp;rdquo;] will be 0.&lt;/p&gt;
&lt;pre class="csharpcode"&gt;        tasteful.SetBinding(codeData, &lt;span class="str"&gt;"Item2"&lt;/span&gt;, &lt;strong&gt;0,&lt;/strong&gt; &lt;span class="str"&gt;"Item1"&lt;/span&gt;); &lt;span class="rem"&gt;// default value 0&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;

&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;The documentation for the new &lt;a href="http://msdn.microsoft.com/en-us/library/gg248905(VS.93).aspx"&gt;SetBinding overload is located here&lt;/a&gt;.&amp;nbsp;Unfortunately the Excel add-in does not take advantage of this new functionality. We hope to address this in a future release.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10120082" width="1" height="1"&gt;</description></item><item><title>Solving non-linear models with Compact Quasi Newton solver part 2</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/12/06/solving-non-linear-models-with-compact-quasi-newton-solver-part-2.aspx</link><pubDate>Mon, 06 Dec 2010 18:35:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10100918</guid><dc:creator>dudeness</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10100918</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/12/06/solving-non-linear-models-with-compact-quasi-newton-solver-part-2.aspx#comments</comments><description>&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3 face=Calibri&gt;In our last &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/solverfoundation/archive/2010/11/15/solving-non-linear-models-with-compact-quasi-newton-solver-part-1.aspx"&gt;&lt;font color=#0000ff size=3 face=Calibri&gt;post&lt;/font&gt;&lt;/a&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt; we described the new API of Solver Foundation 3.0 &lt;span style="COLOR: #1f497d"&gt;for &lt;/span&gt;non-linear model&lt;span style="COLOR: #1f497d"&gt;s&lt;/span&gt;. In particular we described the new API for the Compact Quasi Newton (CQN) solver. We also showed how to model and solve non-linear models using the solver interface. To do this it is necessary to introduce a delegate for getting the value of your goal function and a delegate for setting the gradient to your function. In today’s post we will see how to use Solver Foundation Services to model your problem,&lt;span style="COLOR: #333333"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="COLOR: #333333; mso-ansi-language: EN" lang=EN&gt;without needing to specify derivatives. &lt;/span&gt;&lt;/b&gt;&lt;span style="COLOR: #333333; mso-ansi-language: EN" lang=EN&gt;Solver Foundation Services &lt;/span&gt;&lt;span style="COLOR: #1f497d; mso-ansi-language: EN" lang=EN&gt;uses &lt;/span&gt;Automatic Differentiation&lt;span style="COLOR: #1f497d"&gt; &lt;/span&gt;to specify gradient information, so you don’t have to.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;b&gt;&lt;span style="COLOR: #333333; mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Just like&lt;span style="COLOR: #1f497d"&gt; &lt;/span&gt;in our last post, we consider the&lt;span style="COLOR: #333333"&gt; &lt;/span&gt;&lt;span style="COLOR: #333333; mso-ansi-language: EN" lang=EN&gt;&lt;a href="http://en.wikipedia.org/wiki/Rosenbrock_function"&gt;&lt;font color=#0000ff&gt;Rosenbrock&lt;/font&gt;&lt;/a&gt; &lt;/span&gt;optimization problem. &lt;span style="COLOR: #333333; mso-ansi-language: EN" lang=EN&gt;We will again &lt;/span&gt;use a multi-dimensional variant where each variable is coupled just with one other variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;span style="COLOR: #333333; mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;The steps for modeling and solving non-linear models with Solver Foundation Services are exactly the same as those for any other model type. The model abstraction provided by Solver Foundation Services works just as well. The basic steps are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; BACKGROUND: white; mso-line-height-alt: 10.5pt" class=MsoListParagraph&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt"&gt;1.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create a Solver&lt;span style="COLOR: #1f497d"&gt;C&lt;/span&gt;ontext and a model.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; BACKGROUND: white; mso-line-height-alt: 10.5pt" class=MsoListParagraph&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt"&gt;2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Define your model. This includes the Decisions and the Goal, which is a function of those Decisions. Note that only unconstrained, unbounded models can be solved with CQN, so no constraints are specified.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; BACKGROUND: white; mso-line-height-alt: 10.5pt" class=MsoListParagraph&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt"&gt;3.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Solve the model and optionally report the solution.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;span style="mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Let’s see how those steps are carried out with Solver Foundation Services:&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;span style="mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -24pt; MARGIN: 0in 0in 0pt 42pt; BACKGROUND: white; mso-list: l1 level1 lfo1; mso-line-height-alt: 10.5pt" class=MsoListParagraph&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;1.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt"&gt;Create a Solver context and a model.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;SolverContext&lt;/span&gt; context = &lt;span style="COLOR: #2b91af"&gt;SolverContext&lt;/span&gt;.GetContext();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Model&lt;/span&gt; model = context.CreateModel();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -24pt; MARGIN: auto 0in auto 42pt; TEXT-AUTOSPACE: ; mso-list: l1 level1 lfo1" class=MsoListParagraph&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri; mso-ansi-language: EN" lang=EN&gt;&lt;span style="mso-list: Ignore"&gt;2.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-ansi-language: EN" lang=EN&gt;Next, &lt;span style="COLOR: #1f497d"&gt;y&lt;/span&gt;ou need to define your model. &amp;nbsp;The model always includes definitions for Decision/s and a Goal. In this example it makes sense to use an indexed decision, as the Goal term involves some pattern over some index. We will define a Set, a Decision which is indexed by the Set&lt;span style="COLOR: #1f497d"&gt;,&lt;/span&gt; and a Goal which will be defined with our function to minimize.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; dimensions = 100;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; alpha = 100;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: green"&gt;// Create a Set which the decision will be indexed with &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: #2b91af"&gt;Set&lt;/span&gt; dimensionsSet = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Set&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;Domain&lt;/span&gt;.IntegerRange(1, dimensions), &lt;span style="COLOR: #a31515"&gt;"set"&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: green"&gt;// Create just one decision, indexed by dimensionsSet&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Decision&lt;/span&gt; decision = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Decision&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;Domain&lt;/span&gt;.Real, &lt;span style="COLOR: #a31515"&gt;"x"&lt;/span&gt;, dimensionsSet);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: green"&gt;// Add the decision to the model&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; model.AddDecision(decision);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: green"&gt;// Define the goal. Note that we use ForEachWhere operator, as we only want to go throgh half of the indexes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; model.AddGoal(&lt;span style="COLOR: #a31515"&gt;"theGoal"&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;GoalKind&lt;/span&gt;.Minimize, &lt;span style="COLOR: #2b91af"&gt;Model&lt;/span&gt;.Sum(&lt;span style="COLOR: #2b91af"&gt;Model&lt;/span&gt;.ForEachWhere(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dimensionsSet, &lt;span style="COLOR: green"&gt;/* the set */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (index) =&amp;gt; alpha * (&lt;span style="COLOR: #2b91af"&gt;Model&lt;/span&gt;.Power((decision[2 * index] - decision[2 * index - 1] * decision[2 * index - 1]), 2)) + &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(&lt;span style="COLOR: #2b91af"&gt;Model&lt;/span&gt;.Power(1 - decision[2 * index - 1], 2)), &lt;span style="COLOR: green"&gt;/* the math expression */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (index) =&amp;gt; index &amp;lt;= dimensions / 2 &lt;span style="COLOR: green"&gt;/* the condition */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -24pt; MARGIN: auto 0in auto 42pt; TEXT-AUTOSPACE: ; mso-list: l1 level1 lfo1" class=MsoListParagraph&gt;&lt;span style="mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN" lang=EN&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font face="Times New Roman"&gt;&lt;font size=3&gt;3.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt"&gt;Solve the model with the appropriate directive (for this problem the default call will use the CQN solver as well) and optionally report the solution.&lt;/span&gt;&lt;span style="mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: blue"&gt;var&lt;/span&gt; directive = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;CompactQuasiNewtonDirective&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: blue"&gt;var&lt;/span&gt; sol = context.Solve(directive);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: blue"&gt;var&lt;/span&gt; report = sol.GetReport() &lt;span style="COLOR: blue"&gt;as&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;CompactQuasiNewtonReport&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: green"&gt;// From the report you can get details of the solution such as:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: green"&gt;// report.TotalTime;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: green"&gt;// report.IterationCount&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; COLOR: green; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: green"&gt;// Print out all solution information&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(report);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 12pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Running the code, the output is :&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;===Solver Foundation Service Report===&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Date: 12/3/2010 2:40:51 PM&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Version: Microsoft Solver Foundation 3.0.1.0 Enterprise Edition&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Model Name: DefaultModel&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Capabilities Applied: NLP&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Solve Time (ms): 39&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Total Time (ms): 243&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Solve Completion Status: LocalOptimal&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Solver Selected: Microsoft.SolverFoundation.Solvers.CompactQuasiNewtonSolver&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Directives:&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;CQN(TimeLimit = -1, Tolerance = 1E-07, IterationsToRemember = 17, IterationLimit = 2147483647)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Solver solution quality: LocalOptima.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Iteration count: 22.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Evaluation call count: 28.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Tolerance difference: -2.63557088810946E-08.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;===Solution Details===&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Goals:&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;theGoal: 4.72745153676104E-21&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;font size=3&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;Decisions:&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;x(2): 1.00000000001197&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;x(1): 1.00000000000559&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;x(4): 1.00000000001197&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;x(3): 1.00000000000559&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;x(6): 1.00000000001197&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;x(5): 1.00000000000559&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: 'Cambria','serif'; mso-ansi-language: EN" lang=EN&gt;&lt;font size=3&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Well, that’s it! All you need to do is define your goal in an abstract, mathematical way, and the rest (including automatic differentiation for the solver) is done by the Solver Foundation Services.&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;So, it is very easy and more mathematically descriptive to model your non-linear model with Solver Foundation Services. Also, it is easier to use&lt;span style="COLOR: #1f497d"&gt; a&lt;/span&gt; third party solver if for example you do need to add constraint&lt;span style="COLOR: #1f497d"&gt;s&lt;/span&gt; to your model. What are the disadvantage&lt;span style="COLOR: #1f497d"&gt;s&lt;/span&gt;? In which case&lt;span style="COLOR: #1f497d"&gt;s&lt;/span&gt; you would better off using the solver API? You should consider using the solver API in one of the following cases:&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: auto 0in auto 0.5in; mso-list: l0 level1 lfo2" class=MsoListParagraph&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;-&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt"&gt;Your goal function needs a math operator that is not currently supported in Solver Foundation Services. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: auto 0in auto 0.5in; mso-list: l0 level1 lfo2" class=MsoListParagraph&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;-&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt"&gt;Your model’s dimension (number of Decisions) is very high. Mostly because of the automatic differentiation takes place, using Solver Foundation Services has larger memory footprint, so huge models might benefit from modeling directly against the solver. It depends heavily in the function itself, but around 100,000 Decisions you may consider switching to solver API. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: auto 0in auto 0.5in; mso-list: l0 level1 lfo2" class=MsoListParagraph&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;-&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt"&gt;High dimensionality also effect the time performance, mainly as for the automatic differentiation. If time measure is highly important to you, and your problem is not small, you should at least experiment with the solver API to see if it helps.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;-Solver Foundation Team&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;span style="mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi"&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10100918" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/SFS/">SFS</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/CQN/">CQN</category></item><item><title>Solving non-linear models with Compact Quasi Newton solver part 1</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/11/15/solving-non-linear-models-with-compact-quasi-newton-solver-part-1.aspx</link><pubDate>Mon, 15 Nov 2010 18:58:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10091395</guid><dc:creator>dudeness</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10091395</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/11/15/solving-non-linear-models-with-compact-quasi-newton-solver-part-1.aspx#comments</comments><description>&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3 face=Calibri&gt;Several days ago, &lt;span style="COLOR: #1f497d"&gt;&lt;a href="http://www.solverfoundation.com/Blog.aspx?Entry=91d46819-8472-40ad-a661-2c78acb4018c:10089118"&gt;&lt;font color=#0000ff&gt;Microsoft Solver Foundation 3.0 was released&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;, providing new features to build and solve nonlinear models. These features are at the solver, Solver Foundation Services, and modeling levels. Solver Foundation’s Compact Quasi Newton solver handles unconstrained nonlinear models – it has been supported since version 1.0. Before our 3.0 release, the Compact Quasi Newton solver (CQN) had its own API for modeling and solving unconstrained, unbounded, non-linear models, and there was no access to this solver from Solver Foundation Services. In version 3.0, CQN solver uses the same interfaces that any other third party non-linear solver can use for modeling and solving a non-linear model&lt;span style="COLOR: #1f497d"&gt;: the&lt;/span&gt; &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.solverfoundation.services.inonlinearmodel(VS.93).aspx"&gt;&lt;font color=#0000ff size=3 face=Calibri&gt;INonlinearModel&lt;/font&gt;&lt;/a&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp; and &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.solverfoundation.services.inonlinearsolver(VS.93).aspx"&gt;&lt;font color=#0000ff size=3 face=Calibri&gt;INonlinearSolver&lt;/font&gt;&lt;/a&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt; interfaces. In this post we will show you how to model and solve nonlinear models using the new CQN solver API. In some later post we will &amp;nbsp;show how to use Solver Foundation Services to model your problem, &lt;b&gt;without needing to specify derivatives.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3 face=Calibri&gt;In this walkthrough we consider the &lt;/font&gt;&lt;a href="http://en.wikipedia.org/wiki/Rosenbrock_function"&gt;&lt;font color=#0000ff size=3 face=Calibri&gt;Rosenbrock&lt;/font&gt;&lt;/a&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt; optimization problem. The original problem is a simple function with two dimension&lt;span style="COLOR: #1f497d"&gt;s&lt;/span&gt; (variables) that is often used as a test problem in optimization. The reason we use this function is that it can very easily be expanded to n-dimension&lt;span style="COLOR: #1f497d"&gt;s&lt;/span&gt;. We will use a multi-dimensional variant when each variable is coupled just with one other variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span style="COLOR: #1f497d"&gt;H&lt;/span&gt;ere are the logical steps you need to take in order to model and solve problem with the CQN solver. These steps apply to any other nonlinear solver (with a few small variations).&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;span style="mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3 face=Calibri&gt;1.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Create the modeling object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;span style="mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3 face=Calibri&gt;2.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Define your model. This includes the variables, the function to optimize (the goal) and the gradient vector. Note that only unconstrained, unbounded models can be solved with CQN, no constraints are specified.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;span style="mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3 face=Calibri&gt;3.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Solve the model and optionally report the solution.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Let’s see how those steps are carried out with the new solver API:&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo2" class=MsoListParagraph&gt;&lt;span style="mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3 face=Calibri&gt;1.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Create the solver and parameters. Solver parameters &amp;nbsp;can be used to&lt;span style="COLOR: #1f497d"&gt; &lt;/span&gt;configure solver behavior.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;var&lt;/span&gt; solverParams = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;CompactQuasiNewtonSolverParams&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 12pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;var&lt;/span&gt; solver = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;CompactQuasiNewtonSolver&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; TEXT-AUTOSPACE: ; mso-list: l2 level1 lfo2" class=MsoListParagraph&gt;&lt;span style="mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3 face=Calibri&gt;2.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Next, create the variables. For this sample we are solving the 100 dimensional model, so we create 100 variables. Note that we use null for the variable keys. Keys can be useful if you want to refer to a variable by its key instead of its index. The tradeoff is a bigger memory footprint (to store the keys).&lt;br /&gt;After that, we add a single row for the objective function and register it as a goal. Finally, we define callbacks for function and gradient evaluation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.25in; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp; int&lt;/span&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; dimentions = 100;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; vidRow;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt;[] vidVariables = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt;[dimentions];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// add variables, using null as the key. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;for&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; i = 0; i &amp;lt; dimentions; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; solver.AddVariable(&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;out&lt;/span&gt; vidVariables[i]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//add a row and set it as the minimization goal&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; solver.AddRow(&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;out&lt;/span&gt; vidRow);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; solver.AddGoal(vidRow, 0, &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// set the function and gradient evaluators. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;solver.FunctionEvaluator = RosenbrockFunction;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 12pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; solver.GradientEvaluator = RosenbrockGradient;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; TEXT-AUTOSPACE: ; mso-list: l2 level1 lfo2" class=MsoListParagraph&gt;&lt;span style="mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3 face=Calibri&gt;3.&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Solve the model and print out the result, using the solver’s ToString() override.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//Solve the model&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; solver.Solve(solverParams);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: #a31515"&gt;"== Multidimensional variant of Rosenbrock =="&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(solver.ToString());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;That’s it. Well, not quite, as the interesting part is the definition of the function and gradient callbacks. Let’s see the definition for them:&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Function value callback for first variant of Rosenbrock's function.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; This is the multidimensional variant of Ronsenbrock when n must be pair&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; f(x) = sum(i, from 1 to N){ [alpha(x(2i) - x(2i-1)^2)^2] + [(1 - x(2i-1))^2] }&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="model"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;the model.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="rowVid"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;the row index.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="values"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;the variable values.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="newValues"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;is first evaluator call with those variable values.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;the row value&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;double&lt;/span&gt; RosenbrockFunction(&lt;span style="COLOR: #2b91af"&gt;INonlinearModel&lt;/span&gt; model, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; rowVid, &lt;span style="COLOR: #2b91af"&gt;ValuesByIndex&lt;/span&gt; values, &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; newValues) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; firstVid = 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; alpha = 100;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;double&lt;/span&gt; value = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; dimentions = model.VariableCount;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;for&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; i = firstVid; i &amp;lt;= dimentions / 2; i++) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value += alpha * (&lt;span style="COLOR: #2b91af"&gt;Math&lt;/span&gt;.Pow((values[2 * i] - values[2 * i - 1] * values[2 * i - 1]), 2)) + (&lt;span style="COLOR: #2b91af"&gt;Math&lt;/span&gt;.Pow(1 - values[2 * i - 1], 2));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; value;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gradient value callback for the first variant of Rosenbrock's function.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; This is the multidimensional variant of Ronsenbrock when n must be pair&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; f(x) = sum(i, from 1 to N){ [alpha(x(2i) - x(2i-1)^2)^2] + [(1 - x(2i-1))^2] }&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="model"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;the model.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="rowVid"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;the row index.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="values"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;the variable values.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="newValues"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;is first evaluator call with those variable values.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="gradient"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;the gradient values (set by the user).&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; RosenbrockGradient(&lt;span style="COLOR: #2b91af"&gt;INonlinearModel&lt;/span&gt; model, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; rowVid, &lt;span style="COLOR: #2b91af"&gt;ValuesByIndex&lt;/span&gt; values, &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; newValues, &lt;span style="COLOR: #2b91af"&gt;ValuesByIndex&lt;/span&gt; gradient) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; firstVid = 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; alpha = 100;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; dimentions = model.VariableCount;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;for&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; i = firstVid; i &amp;lt;= dimentions / 2; i++) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gradient[2 * i - 1] = (4 * alpha * values[2 * i - 1] * (values[2 * i - 1] * values[2 * i - 1] - values[2 * i]) + 2 * values[2 * i - 1] - 2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gradient[2 * i] = (2 * alpha * -1 * (values[2 * i - 1] * values[2 * i - 1] - values[2 * i]));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: " class=MsoNormal&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;b&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;There are few types and concepts worth mentioning.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo3" class=MsoListParagraph&gt;&lt;span style="mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3 face=Calibri&gt;-&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;b&gt;ValuesByIndex – &lt;/b&gt;This type allows you to map from a variable index to underlying solver value. The&lt;span style="COLOR: #1f497d"&gt; &lt;/span&gt;&lt;i&gt;values&lt;/i&gt; argument represent the current value&lt;span style="COLOR: #1f497d"&gt;s&lt;/span&gt; for&lt;span style="COLOR: #1f497d"&gt; &lt;/span&gt;the variables when the callback is called, so the function and gradient callbacks can &lt;b&gt;get&lt;/b&gt; the values in order to compute the function value and the gradient values. &lt;span style="COLOR: #1f497d"&gt;If&lt;/span&gt; for example there is a variable with index x, &amp;nbsp;values[x] is the current value of x.&lt;/font&gt;&lt;/font&gt;&lt;span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt; &lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;The &lt;i&gt;gradient&lt;/i&gt; argument represents the gradient value associated with each variable, so if for example there is a variable with index x, &amp;nbsp;&amp;nbsp;gradient[x] represent the value of df/dx. Gradient evaluator uses gradient argument to &lt;strong&gt;set&lt;/strong&gt; the right value for the gradient.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo3" class=MsoListParagraph&gt;&lt;span style="mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3 face=Calibri&gt;-&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;b&gt;Index allocation convention &lt;/b&gt;– There is a convention for how &lt;span style="COLOR: #1f497d"&gt;the &lt;/span&gt;CQN solver allocate&lt;span style="COLOR: #1f497d"&gt;s &lt;/span&gt;variable and row indexes. By convention variables get indexes from 1 ... VariableCount, &lt;span style="COLOR: #1f497d"&gt;in&lt;/span&gt; the order they were added. The only row (the goal) will always get the index 0. You can rely on this convention in your callbacks to access variable and row indexes without having to do any bookkeeping. In fact, notice that we did not use the vidVariables array after creating the variables, and we could have even omitted it altogether. &lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo3" class=MsoListParagraph&gt;&lt;span style="mso-fareast-font-family: Calibri"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3 face=Calibri&gt;-&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir=ltr&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;b&gt;bool newValues&lt;/b&gt; – This Boolean flag indicates if this is first evaluator call with those variable values. This can be used to make the computation of gradients in your evaluator more efficient, as long as you have some computation on the function callback, which can be carried over to be used when computing the gradient. For each point, CQN solver always calls the function evaluator first followed by gradient evaluator. Therefore this Boolean will always be true when function evaluator is called, and false when gradient evaluator is called. In this sample code we did not take advantage of this flag.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;With that in mind, the rest is straightforward. The function evaluator gets back the value of the function in the current point, and the gradient evaluator sets the values for the gradient. &lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Running the code, the output is :&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;== Multidimensional variant of Rosenbrock ==&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Minimize problem&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Dimensions = 100&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Variable indexes:&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;1, 2, 3, 4, 5, 6, 7, 8, 9, 10...&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Starting point = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Solution quality is: LocalOptima&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Number of iterations performed: 22&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Number of evaluation calls: 28&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Finishing point =1.00000000000559, 1.00000000001197, 1.00000000000559, 1.00000000001197, 1.00000000000559, 1.00000000001197, 1.00000000000559, 1.00000000001197, 1.00000000000559, 1.00000000001197...&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Finishing value =4.72745153676104E-21&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;All of this information can also be programmatically accessed from the solver through methods or properties.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;The code for this sample is a modification of code provide as a sample project in your document directory under “…\Documents\Microsoft Solver Foundation\Samples\Solvers\C#\CQN”.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;In the next post, we will consider the following question: how would you model Rosenbrock function optimization using the Solver Foundation Services&lt;span style="COLOR: #1f497d"&gt;?&lt;/span&gt; (Hint: easily, naturally and with no gradient definition&lt;span style="COLOR: #1f497d"&gt;!&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;-Solver Foundation Team&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;font size=3 face=Calibri&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10091395" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/CQN/">CQN</category></item><item><title>Microsoft Solver Foundation v3.0 Released</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/11/10/microsoft-solver-foundation-v3-0-released.aspx</link><pubDate>Wed, 10 Nov 2010 20:53:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10089118</guid><dc:creator>solverfoundation</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10089118</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/11/10/microsoft-solver-foundation-v3-0-released.aspx#comments</comments><description>&lt;p&gt;We pleased to announce the release of &lt;a href="http://solverfoundation.com"&gt;Microsoft Solver Foundation&lt;/a&gt; v3.0. The Express edition is available at &lt;a href="http://code.msdn.microsoft.com/solverfoundation"&gt;http://code.msdn.microsoft.com/solverfoundation&lt;/a&gt;. The Standard and Academic Editions of Solver Foundation v3.0 will soon be available online via MSDN and MSDNAA subscriber downloads. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.modelingtheworld.com/"&gt;Microsoft Technical Computing&lt;/a&gt;&amp;rsquo;s Solver Foundation provides a complete system for model specification, connection to data sources, and access to best-of-breed solvers for Excel users and .Net programmers. Version 3.0 greatly extends the range of real-world models that can be modeled and solved by Solver Foundation, in particular those involving nonlinear expressions. Here is a partial list of new features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A new hybrid local search solver designed to tackle nonlinear models including nonconvex and/or nondifferentiable functions.&lt;/li&gt;
&lt;li&gt;Mixed integer quadratic programming (MIQP) plug-in support. The just-released &lt;a href="http://gurobi.com"&gt;Gurobi 4.0&lt;/a&gt; solver is the default MIP and MIQP solver for Solver Foundation.&lt;/li&gt;
&lt;li&gt;Full plug-in support for nonlinear and mixed-integer nonlinear solvers, making Solver Foundation the ideal platform for solver experimentation and innovation.&lt;/li&gt;
&lt;li&gt;Access to many new third-party solvers using the new &lt;a href="http://ziena.com/"&gt;KNITRO&lt;/a&gt; and &lt;a href="http://solver.com/"&gt;Frontline Solver Platform SDK&lt;/a&gt; plug-ins.&lt;/li&gt;
&lt;li&gt;The Compact Quasi-Newton solver is fully accessible from OML and SFS - without the need for specifying gradient information.&lt;/li&gt;
&lt;li&gt;18 new OML operators: If, Exp, Log, Floor, Ceiling, Sin, Cosh, ArcTan, etc.&lt;/li&gt;
&lt;li&gt;Automatic differentiation (forward and backward).&lt;/li&gt;
&lt;li&gt;Solver Foundation Services improvements:
&lt;ul&gt;
&lt;li&gt;Solver selection&lt;/li&gt;
&lt;li&gt;Sparse parameters&lt;/li&gt;
&lt;li&gt;Multiple model support&lt;/li&gt;
&lt;li&gt;Better C# export&lt;/li&gt;
&lt;li&gt;Extended exception object model&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The only system requirement for using Solver Foundation is .Net 4.0. Excel 2007 or Excel 2010 is required to use the Excel add-in. Try out the &lt;a href="http://code.msdn.microsoft.com/solverfoundation"&gt;Express version&lt;/a&gt; and let us know what you think!&lt;/p&gt;
&lt;p&gt;The Solver Foundation Team&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10089118" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Technical+Computing/">Technical Computing</category></item><item><title>Solver Foundation at INFORMS 2010</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/11/05/solver-foundation-at-informs-2010.aspx</link><pubDate>Fri, 05 Nov 2010 22:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10086944</guid><dc:creator>Nate Brixius</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10086944</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/11/05/solver-foundation-at-informs-2010.aspx#comments</comments><description>&lt;p&gt;The &lt;a href="http://www.solverfoundation.com" title="http://www.solverfoundation.com"&gt;Solver Foundation&lt;/a&gt; team will once again be at the &lt;a href="http://meetings2.informs.org/austin2010/" title="http://meetings2.informs.org/austin2010/"&gt;INFORMS annual meeting&lt;/a&gt;, this year in Austin, Texas. We will be showcasing our upcoming release featuring nonlinear optimization, mixed integer quadratic programming, new OML operators, SFS improvements, and much more. Drop by our presentation on Sunday - &lt;a href="http://meetings2.informs.org/austin2010/softwaredemos.html"&gt;click here&lt;/a&gt; for more details.&lt;/p&gt;
&lt;p&gt;During the conference we will release Solver Foundation 3.0 to the web. The Express version will be available on our &lt;a href="http://code.msdn.microsoft.com/solverfoundation/" title="http://code.msdn.microsoft.com/solverfoundation/"&gt;MSDN site&lt;/a&gt;, with the Standard version available for MSDN subscribers shortly thereafter.&lt;/p&gt;
&lt;p&gt;See you in Austin!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10086944" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Technical+Computing/">Technical Computing</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/INFORMS/">INFORMS</category></item><item><title>The next release of Solver Foundation</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/09/29/the-next-release-of-solver-foundation.aspx</link><pubDate>Wed, 29 Sep 2010 16:20:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10069338</guid><dc:creator>solverfoundation</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10069338</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/09/29/the-next-release-of-solver-foundation.aspx#comments</comments><description>&lt;p&gt;The Solver Foundation team has been hard at work on our next release. We want to take a break from the action to share some details about we plan to ship. Our focus is to broaden the range of real-world models that can be created, solved and analyzed using Solver Foundation Services (SFS) and OML. Here are some of the features we plan to include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A new local search solver that covers the full expressiveness of SFS.&lt;/li&gt;
&lt;li&gt;The Compact Quasi-Newton solver will fully accessible from OML and SFS - without the need for specifying gradient information.&lt;/li&gt;
&lt;li&gt;18 new OML operators: If, Exp, Log, Floor, Ceiling, Sin, Cosh, ArcTan, etc.&lt;/li&gt;
&lt;li&gt;Full plug-in support for nonlinear and mixed-integer nonlinear solvers. Metaheuristic and gradient-based solvers alike can be easily plugged into Solver Foundation.&lt;/li&gt;
&lt;li&gt;Automatic differentiation support.&lt;/li&gt;
&lt;li&gt;New plug-in solvers.&lt;/li&gt;
&lt;li&gt;Mixed integer quadratic programming (MIQP) plug-in support.&lt;/li&gt;
&lt;li&gt;Improved exception object model, including programmatically accessible location information.&lt;/li&gt;
&lt;li&gt;Solver Foundation Services improvements, including multiple model support.&lt;/li&gt;
&lt;li&gt;Improved Excel add-in data binding support.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The next version of Solver Foundation will require .Net 4.0, because it takes advantage of new .Net 4.0 features. Existing Solver Foundation code, OML models, and plug-in solvers will continue to work without changes. &lt;/p&gt;
&lt;p&gt;We will update the blog and MSDN forum with more information about the release as we draw closer to our November release. &lt;/p&gt;
&lt;p&gt;- Solver Foundation Team&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10069338" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Technical+Computing/">Technical Computing</category></item><item><title>Gurobi 3.0 Plug-in for Microsoft Solver Foundation 2.1</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/09/16/gurobi-3-0-plug-in-for-microsoft-solver-foundation-2-1.aspx</link><pubDate>Thu, 16 Sep 2010 21:52:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10063567</guid><dc:creator>solverfoundation</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10063567</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/09/16/gurobi-3-0-plug-in-for-microsoft-solver-foundation-2-1.aspx#comments</comments><description>&lt;p&gt;Solver Foundation developers can update their environment to use the latest solver from &lt;a target="_blank" href="http://www.gurobi.com"&gt;Gurobi&lt;/a&gt;. In the &lt;a href="http://code.msdn.microsoft.com/solverfoundation/Release/ProjectReleases.aspx?ReleaseId=1799"&gt;Downloads&lt;/a&gt; area of the MSDN gallery site, the files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Gurobi 3.0 Solver and Plug-In for Microsoft Solver Foundation - 32-bit&lt;/li&gt;
&lt;li&gt;Gurobi 3.0 Solver and Plug-In for Microsoft Solver Foundation - 64-bit &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;are now online and ready for use. The download includes an updated solver along with installation instructions and an update to the Gurobi-SolverProgrammingPrimer.&lt;/p&gt;
&lt;p&gt;The Solver Foundation Team&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10063567" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category></item><item><title>VBA integration for Solver Foundation</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/30/vba-integration-for-solver-foundation.aspx</link><pubDate>Wed, 30 Jun 2010 15:15:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10032855</guid><dc:creator>Nate Brixius</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10032855</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/30/vba-integration-for-solver-foundation.aspx#comments</comments><description>&lt;p&gt;In Solver Foundation 2.1 we added very basic support for VBA in the Excel Add-In. By obtaining the MSF add-in COM object you can call Solve, which has the same effect as clicking the “Solve” button in the Solver Foundation Ribbon: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-36-42-metablogapi/5148.image_5F00_276B4C00.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" class="wlDisabledImage" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-36-42-metablogapi/8272.image_5F00_thumb_5F00_5026B149.png" width="244" height="111" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here is a code sample:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;Sub&lt;/span&gt; CallSolve()
  &lt;span class="rem"&gt;' Get the MSFForExcel COM object&lt;/span&gt;
  &lt;span class="kwrd"&gt;Dim&lt;/span&gt; oAddin &lt;span class="kwrd"&gt;As&lt;/span&gt; COMAddIn
  &lt;span class="kwrd"&gt;Dim&lt;/span&gt; oCOMFuncs &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;
  &lt;span class="kwrd"&gt;Set&lt;/span&gt; oAddin = Application.COMAddIns(&lt;span class="str"&gt;&amp;quot;MicrosoftSolverFoundationForExcel&amp;quot;&lt;/span&gt;)
  &lt;span class="kwrd"&gt;Set&lt;/span&gt; oCOMFuncs = oAddin.&lt;span class="kwrd"&gt;Object&lt;/span&gt;
 
  &lt;span class="rem"&gt;' Solve&lt;/span&gt;
  oCOMFuncs.Solve
 
&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;


&lt;br /&gt;

&lt;p&gt;To access solver results you can write VBA code to access the data in the “Solver Foundation Results” sheet. For cases where the VBA Solve method is insufficient, we recommend writing a VSTO add-in, which allows you to access the full power of Solver Foundation. The Sudoku sample (Documents\Microsoft Solver Foundation\Samples\SolverFoundationServices\VB.NET\Sudoku) shows you how to build a VSTO add-in that uses Solver Foundation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10032855" width="1" height="1"&gt;</description></item><item><title>Simpler Data Binding using LINQ and extension methods</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/28/simpler-data-binding-using-linq-and-extension-methods.aspx</link><pubDate>Tue, 29 Jun 2010 04:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10031912</guid><dc:creator>Nate Brixius</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10031912</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/28/simpler-data-binding-using-linq-and-extension-methods.aspx#comments</comments><description>&lt;p&gt;In this post we introduce some utility methods to make it easier to work with arrays in Solver Foundation programs. Most real models involve either input parameters or output decision variables that involve collections. For example, in an investment portfolio optimization model we may have an input parameter that represents the mean return for each potential investment in the portfolio. In such a case the mean return may be stored in an array of doubles. In the Solver Foundation model, we&amp;rsquo;d define a Set for the investment types, and then define a parameter &amp;ldquo;meanReturn&amp;rdquo; that is indexed by that set.&amp;nbsp; Then we would call SetBinding to associate the array with the Parameter. But have a look at the signature for &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ff526687(v=VS.93).aspx"&gt;Parameter.SetBinding&lt;/a&gt;:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;void&lt;/span&gt; SetBinding&amp;lt;T&amp;gt;(IEnumerable&amp;lt;T&amp;gt; binding, &lt;span class="kwrd"&gt;string&lt;/span&gt; valueField, &lt;span class="kwrd"&gt;params&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;[] indexFields);&lt;/pre&gt;
&lt;p&gt;It&amp;rsquo;s not at all obvious what to do! The first entry should obviously be the array (since arrays implement IEnumerable), but what should we fill in for the &amp;ldquo;valueField&amp;rdquo;? If I had an array of objects, I would fill in the name for the property on the object that returned the mean return. But in this case I have an array of doubles. One way to handle this problem would be to transform the array of doubles into an array of objects with the right type. But it&amp;rsquo;s a pain to do this each time I want to bind to an array. So why not write some utility methods that automatically do this work?&amp;nbsp; Here goes:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;Bind an indexed parameter to an IEnumerable of values.&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetBinding(&lt;span class="kwrd"&gt;this&lt;/span&gt; Parameter parameter, IEnumerable&amp;lt;&lt;span class="kwrd"&gt;double&lt;/span&gt;&amp;gt; data) {
      parameter.SetBinding(ToIEnumerable(data), &lt;span class="str"&gt;"Value"&lt;/span&gt;, &lt;span class="str"&gt;"Key"&lt;/span&gt;);
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IEnumerable&amp;lt;KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, T&amp;gt;&amp;gt; ToIEnumerable&amp;lt;T&amp;gt;(IEnumerable&amp;lt;T&amp;gt; vector) {
      &lt;span class="kwrd"&gt;return&lt;/span&gt; vector.Select((d, index) =&amp;gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, T&amp;gt;(index, d));
    }&lt;/pre&gt;
&lt;p&gt;

&lt;/p&gt;
&lt;p&gt;I have added a method called SetBinding. The &amp;ldquo;this&amp;rdquo; before the first argument means that SetBinding is an &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/bb383977.aspx"&gt;extension method&lt;/a&gt;, which means we can call it as if it were a member of the Parameter class. The body of the method calls a utility function called ToIEnumerable. ToIEnumerable simply does a LINQ Select on the data, transforming it into an IEnumerable of (key, value) pairs. Now we&amp;rsquo;ve got what we want! We pass it into SetBinding, specifying &amp;ldquo;Value&amp;rdquo; and &amp;ldquo;Key&amp;rdquo; for the value and index fields, respectively.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Notice that I can do the same thing for scalar parameters (parameters with 0 indexes) and &amp;ldquo;matrix parameters&amp;rdquo; (parameters with 2 indexes). A similar issue exists for getting results. Sometimes I just want to get an array of doubles corresponding to the values for a 1-indexed Decision. Using LINQ it&amp;rsquo;s easy to pull the values out of the Decision.GetValues method and push them into an array.&amp;nbsp; I can wrap all of this stuff into a new class &amp;ndash; here it is. (Note that some of the standard argument checking has been left out for brevity):&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Globalization;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq.Expressions;
&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.SolverFoundation.Common;
&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.SolverFoundation.Services;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; SolverFoundation.Samples {
  &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;Helper methods for Parameter and Decision data binding.&lt;/span&gt;
  &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; BindingUtilities {

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;Bind a parameter to a scalar value.&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetBinding(&lt;span class="kwrd"&gt;this&lt;/span&gt; Parameter parameter, &lt;span class="kwrd"&gt;double&lt;/span&gt; data) {
      parameter.SetBinding(ToIEnumerable(data), &lt;span class="str"&gt;"Value"&lt;/span&gt;);
    }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;Bind an indexed parameter to an IEnumerable of values.&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetBinding(&lt;span class="kwrd"&gt;this&lt;/span&gt; Parameter parameter, IEnumerable&amp;lt;&lt;span class="kwrd"&gt;double&lt;/span&gt;&amp;gt; data) {
      parameter.SetBinding(ToIEnumerable(data), &lt;span class="str"&gt;"Value"&lt;/span&gt;, &lt;span class="str"&gt;"Key"&lt;/span&gt;);
    }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;Bind an indexed parameter to a table.&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetBinding(&lt;span class="kwrd"&gt;this&lt;/span&gt; Parameter parameter, IEnumerable&amp;lt;IEnumerable&amp;lt;&lt;span class="kwrd"&gt;double&lt;/span&gt;&amp;gt;&amp;gt; data) {
      parameter.SetBinding(ToIEnumerable(data), &lt;span class="str"&gt;"Item3"&lt;/span&gt;, &lt;span class="str"&gt;"Item1"&lt;/span&gt;, &lt;span class="str"&gt;"Item2"&lt;/span&gt;);
    }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;Gets the values for a decision with one index Set.&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;An IEnumerable containing the values.&amp;lt;/returns&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;remarks&amp;gt;The values are returned ordered by index.&amp;lt;/remarks&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IEnumerable&amp;lt;&lt;span class="kwrd"&gt;double&lt;/span&gt;&amp;gt; GetValuesByIndex(&lt;span class="kwrd"&gt;this&lt;/span&gt; Decision decision) {
      &lt;span class="rem"&gt;// GetValues returns the values in order of index --&amp;gt; no need to sort.&lt;/span&gt;
      &lt;span class="kwrd"&gt;return&lt;/span&gt; decision.GetValues().Select(r =&amp;gt; Convert.ToDouble(r[0]));
    }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;Gets the values for a decision with two index Sets.&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;An IEnumerable containing the values, grouped by the first index.&amp;lt;/returns&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;remarks&amp;gt;The values are returned ordered by index.&amp;lt;/remarks&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IEnumerable&amp;lt;IEnumerable&amp;lt;&lt;span class="kwrd"&gt;double&lt;/span&gt;&amp;gt;&amp;gt; GetValuesByFirstIndex(&lt;span class="kwrd"&gt;this&lt;/span&gt; Decision decision) {
      &lt;span class="rem"&gt;// GetValues returns the values in order of index --&amp;gt; no need to sort.&lt;/span&gt;
      &lt;span class="kwrd"&gt;return&lt;/span&gt; decision.GetValues().GroupBy(r =&amp;gt; r[1]).Select(g =&amp;gt; g.Select(r =&amp;gt; Convert.ToDouble(r[0])));
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IEnumerable&amp;lt;KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, T&amp;gt;&amp;gt; ToIEnumerable&amp;lt;T&amp;gt;(T &lt;span class="kwrd"&gt;value&lt;/span&gt;) {
      &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, T&amp;gt;[] { &lt;span class="kwrd"&gt;new&lt;/span&gt; KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, T&amp;gt;(0, &lt;span class="kwrd"&gt;value&lt;/span&gt;) };
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IEnumerable&amp;lt;KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, T&amp;gt;&amp;gt; ToIEnumerable&amp;lt;T&amp;gt;(IEnumerable&amp;lt;T&amp;gt; vector) {
      &lt;span class="kwrd"&gt;return&lt;/span&gt; vector.Select((d, index) =&amp;gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, T&amp;gt;(index, d));
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IEnumerable&amp;lt;Tuple&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, &lt;span class="kwrd"&gt;int&lt;/span&gt;, T&amp;gt;&amp;gt; ToIEnumerable&amp;lt;T&amp;gt;(IEnumerable&amp;lt;IEnumerable&amp;lt;T&amp;gt;&amp;gt; matrix) {
      var m = matrix.Select((row, i) =&amp;gt; row.Select((cell, j) =&amp;gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Tuple&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, &lt;span class="kwrd"&gt;int&lt;/span&gt;, T&amp;gt;(i, j, cell)));
      var cells = from cell &lt;span class="kwrd"&gt;in&lt;/span&gt; m.SelectMany(c =&amp;gt; c) select cell;
      &lt;span class="kwrd"&gt;return&lt;/span&gt; cells;
    }
  }
}&lt;/pre&gt;
&lt;p&gt;Once I have this class, life is much simpler whenever I want to bind parameters to arrays (or lists). For example, here is a C# program that builds and solves the portfolio optimization model I introduced earlier. I have obnoxiously put four lines in large bold type to show you where the utility functions are called. Very simple!&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;
&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.SolverFoundation.Services;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; SolverFoundation.Samples {
  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; QuadraticPortfolioSample {
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt;[] Solve(&lt;span class="kwrd"&gt;double&lt;/span&gt; required, &lt;span class="kwrd"&gt;double&lt;/span&gt;[] meanReturn, &lt;span class="kwrd"&gt;double&lt;/span&gt;[][] covar) {
      SolverContext context = SolverContext.GetContext();
      Model model = context.CreateModel();

      Set I = &lt;span class="kwrd"&gt;new&lt;/span&gt; Set(Domain.Any, &lt;span class="str"&gt;"I"&lt;/span&gt;);
      Set J = &lt;span class="kwrd"&gt;new&lt;/span&gt; Set(Domain.Any, &lt;span class="str"&gt;"J"&lt;/span&gt;);

      Parameter requiredReturn = &lt;span class="kwrd"&gt;new&lt;/span&gt; Parameter(Domain.Real, &lt;span class="str"&gt;"RequiredReturn"&lt;/span&gt;);
      Parameter mean = &lt;span class="kwrd"&gt;new&lt;/span&gt; Parameter(Domain.Real, &lt;span class="str"&gt;"Mean"&lt;/span&gt;, I);
      Parameter cov = &lt;span class="kwrd"&gt;new&lt;/span&gt; Parameter(Domain.Real, &lt;span class="str"&gt;"Cov"&lt;/span&gt;, I, J);
      model.AddParameters(requiredReturn, mean, cov);

      Decision allocation = &lt;span class="kwrd"&gt;new&lt;/span&gt; Decision(Domain.RealRange(0, 1), &lt;span class="str"&gt;"Allocation"&lt;/span&gt;, I);
      Decision portfolioYield = &lt;span class="kwrd"&gt;new&lt;/span&gt; Decision(Domain.RealNonnegative, &lt;span class="str"&gt;"Yield"&lt;/span&gt;);
      model.AddDecisions(allocation, portfolioYield);

      model.AddConstraint(&lt;span class="str"&gt;"c1"&lt;/span&gt;, (portfolioYield &amp;gt;= requiredReturn));
      model.AddConstraint(&lt;span class="str"&gt;"c2"&lt;/span&gt;, (Model.Sum(Model.ForEach(I, i =&amp;gt; allocation[i])) == 1));
      model.AddConstraint(&lt;span class="str"&gt;"c3"&lt;/span&gt;, (Model.Sum(Model.ForEach(I, i =&amp;gt; (mean[i] * allocation[i]))) == portfolioYield));
      model.AddGoal(&lt;span class="str"&gt;"Variance"&lt;/span&gt;, GoalKind.Minimize,
        Model.Sum(Model.ForEach(I, i =&amp;gt; Model.ForEach(J, j =&amp;gt; Model.Product(cov[i, j], allocation[i], allocation[j]))))
        );

&lt;span style="font-size: medium;"&gt;&lt;strong&gt;      requiredReturn.SetBinding(required);
      mean.SetBinding(meanReturn);
      cov.SetBinding(covar);

&lt;/strong&gt;&lt;/span&gt;      var solution = context.Solve();
&lt;span style="font-size: medium;"&gt;&lt;strong&gt;      &lt;span class="kwrd"&gt;return&lt;/span&gt; allocation.GetValuesByIndex().ToArray();
&lt;/strong&gt;&lt;/span&gt;    }
  }
}&lt;/pre&gt;
&lt;p&gt;Now it&amp;rsquo;s a breeze to call this method to solve portfolio optimization models. Look:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; TryIt() {
      QuadraticPortfolioSample m = &lt;span class="kwrd"&gt;new&lt;/span&gt; QuadraticPortfolioSample();
      &lt;span class="kwrd"&gt;double&lt;/span&gt; requiredReturn = 0.06;
      &lt;span class="kwrd"&gt;double&lt;/span&gt;[] meanReturn = { .1322, .0824, .0903, .0873, .0629, .0910 };
      var covar = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt;[][] {
        &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt;[] {0.006650561,    0.000261280,    0.000217891,    0.003089108,    0.000137570,    0.002071282},
        &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt;[] {0.000261280,    0.000062715,    0.000048178,    0.000326722,    -0.000043052,    0.000131168},
        &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt;[] {0.000217891,    0.000048178,    0.000037676,    0.000321380,    -0.000031673,    0.000118690},
        &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt;[] {0.003089108,    0.000326722,    0.000321380,    0.014783517,    0.001100947,    0.003924335},
        &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt;[] {0.000137570,    -0.000043052,    -0.000031673,    0.001100947,    0.000372023,    0.000307163},
        &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt;[] {0.002071282,    0.000131168,    0.000118690,    0.003924335,    0.000307163,    0.001310528}
      };&lt;/pre&gt;
&lt;pre class="csharpcode"&gt;      // the following line is awesome in its simplicity.
      &lt;span class="kwrd"&gt;double&lt;/span&gt;[] allocation = QuadraticPortfolioSample.Solve(requiredReturn, meanReturn, covar);
      &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; allocation.Length; i++) {
        Console.WriteLine(&lt;span class="str"&gt;"{0}\t{1}"&lt;/span&gt;, i, allocation[i].ToString(&lt;span class="str"&gt;"P"&lt;/span&gt;));
      }
    }&lt;/pre&gt;
&lt;p&gt;Let us know if you find these utility methods useful!&lt;/p&gt;
&lt;p&gt;



&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10031912" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/LINQ/">LINQ</category><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/SFS/">SFS</category></item><item><title>Use indices instead of keys to reference model elements</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/22/use-indices-instead-of-keys-to-reference-model-elements.aspx</link><pubDate>Tue, 22 Jun 2010 17:47:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10028621</guid><dc:creator>solverfoundation</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10028621</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/22/use-indices-instead-of-keys-to-reference-model-elements.aspx#comments</comments><description>&lt;p&gt;In the 2.1 release of Microsoft Solver Foundation, there is a bug in the sample plug-in for the XpressMPSolver. For improved performance variable/row keys are no longer specified by Solver foundation services when creating LinearModel object. In order to work correctly, the source for the XpressMPSolver plug-in should be modified to use indices instead of keys.&lt;/p&gt;  &lt;p&gt;The following code in XpressMPSolver.cs (from line 567) in method BuildModel() &lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre id="codeSnippet" class="csharpcode"&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (!IsGoal(GetIndexFromKey(entry.Key)) &amp;amp;&amp;amp;&lt;br /&gt;    !IsSOS1Row(GetIndexFromKey(entry.Key)) &amp;amp;&amp;amp;&lt;br /&gt;    !IsSOS2Row(GetIndexFromKey(entry.Key))) {&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;need to be changed as below to fix the issue:&lt;/p&gt;

&lt;div&gt;
  &lt;pre id="codeSnippet" class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (!IsGoal(entry.Index) &amp;amp;&amp;amp;&lt;br /&gt;    !IsSOS1Row(entry.Index) &amp;amp;&amp;amp;&lt;br /&gt;    !IsSOS2Row(entry.Index)) {&lt;/pre&gt;
&lt;/div&gt;

&lt;div&gt;&lt;/div&gt;

&lt;p&gt;Alternatively, download the source code from &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=solverfoundation&amp;amp;DownloadId=12842"&gt;http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=solverfoundation&amp;amp;DownloadId=12842&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10028621" width="1" height="1"&gt;</description></item><item><title>Microsoft Solver Foundation Customer Feedback Survey</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/08/microsoft-solver-foundation-customer-feedback-survey.aspx</link><pubDate>Tue, 08 Jun 2010 18:02:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10021786</guid><dc:creator>solverfoundation</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10021786</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/08/microsoft-solver-foundation-customer-feedback-survey.aspx#comments</comments><description>&lt;p&gt;The Solver Foundation team is interested in your experience with the product. Please complete the short survey linked to below and share your thoughts on the current release and prioritization of areas for future releases.&lt;/p&gt;  &lt;p&gt;Thanks for your time!&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.surveymonkey.com/s/M57DS8S" href="http://www.surveymonkey.com/s/M57DS8S"&gt;http://www.surveymonkey.com/s/M57DS8S&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10021786" width="1" height="1"&gt;</description></item><item><title>Relaxing mixed integer models with Solver Foundation</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/07/relaxing-mixed-integer-models-with-solver-foundation.aspx</link><pubDate>Mon, 07 Jun 2010 22:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10021245</guid><dc:creator>Nate Brixius</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10021245</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/07/relaxing-mixed-integer-models-with-solver-foundation.aspx#comments</comments><description>&lt;p&gt;Mixed integer programming (MIP) models are one of the most commonly formulated Solver Foundation model types. &amp;ldquo;Mixed&amp;rdquo; refers to the fact that such models contain both integer and continuous (real) decision variables. People frequently want to solve the &amp;ldquo;relaxation&amp;rdquo; of a MIP model: the model where all variables are assumed to be real. It&amp;rsquo;s a simple matter to solve the relaxation with Solver Foundation by adding a little logic to supply the right &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.solverfoundation.services.domain(v=VS.93).aspx"&gt;Domain&lt;/a&gt; for each Decision.&amp;nbsp; Here is a simple example of a MIP model:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Production() {
      SolverContext context = SolverContext.GetContext();
      Model model = context.CreateModel();

      Decision xs = &lt;span class="kwrd"&gt;new&lt;/span&gt; Decision(Domain.IntegerNonnegative, &lt;span class="str"&gt;"Number_of_small_chess_boards"&lt;/span&gt;);
      Decision xl = &lt;span class="kwrd"&gt;new&lt;/span&gt; Decision(Domain.IntegerNonnegative, &lt;span class="str"&gt;"Number_of_large_chess_boards"&lt;/span&gt;);
      model.AddDecisions(xs, xl);

      Constraint constraintBoxWood = model.AddConstraint(&lt;span class="str"&gt;"BoxWood"&lt;/span&gt;, 1 * xs + 3 * xl &amp;lt;= 200);
      Constraint constraintLathe = model.AddConstraint(&lt;span class="str"&gt;"Lathe"&lt;/span&gt;, 3 * xs + 2 * xl &amp;lt;= 160);

      model.AddGoal(&lt;span class="str"&gt;"Profit"&lt;/span&gt;, GoalKind.Maximize, 5 * xs + 20 * xl);

      Solution sol = context.Solve();
      Report report = sol.GetReport();
      Console.WriteLine(report);
    }
&lt;/pre&gt;
&lt;p&gt;The xs and xl decisions have domain &amp;ldquo;IntegerNonnegative&amp;rdquo;. In Visual Studio, highlight one of the domain statements and right click to extract a new method:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-36-42-metablogapi/2018.Refactor_5F00_571650B3.png"&gt;&lt;img height="81" width="839" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-36-42-metablogapi/3835.Refactor_5F00_thumb_5F00_43F52407.png" alt="Refactor" border="0" title="Refactor" style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" /&gt;&lt;/a&gt; &lt;/pre&gt;
&lt;p&gt;

&lt;/p&gt;
&lt;p&gt;Call the method GetDomain.&amp;nbsp; Now, let&amp;rsquo;s add an automatic property that determines whether we&amp;rsquo;re going to solve the relaxation. If this property is true, then GetDomain should return RealNonnegative instead of IntegerNonnegative:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; SolveRelaxation { get; set; }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; Domain GetDomain() {
      &lt;span class="kwrd"&gt;return&lt;/span&gt; SolveRelaxation ? Domain.RealNonnegative : Domain.IntegerNonnegative;
    }&lt;/pre&gt;
&lt;p&gt;

Here is a simple Main method for a console application. If the user supplies any command-line arguments then the relaxation is solved instead of the original problem.&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args) {
      Program p = &lt;span class="kwrd"&gt;new&lt;/span&gt; Program();
      p.SolveRelaxation = args.Length &amp;gt; 0;
      p.Production();
    }&lt;/pre&gt;
&lt;p&gt;

This simple logic can be wrapped in a class so that it can be used whenever you like.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10021245" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/solverfoundation/archive/tags/Solver+Foundation/">Solver Foundation</category></item><item><title>Math Modeling Tricks:  Absolute Values</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/02/math-modeling-tricks-absolute-values.aspx</link><pubDate>Wed, 02 Jun 2010 19:51:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10019075</guid><dc:creator>solverfoundation</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10019075</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/02/math-modeling-tricks-absolute-values.aspx#comments</comments><description>&lt;p&gt;In a previous post, we discussed &lt;a href="http://blogs.msdn.com/b/solverfoundation/archive/2010/06/01/math-modeling-tricks-min-max-problems.aspx"&gt;modeling tricks for min-max problems&lt;/a&gt;.&amp;#160; From there, it is simple to handle absolute values as well.&amp;#160; Consider a problem of the form&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;minimize Abs( &lt;strong&gt;a&lt;/strong&gt; * &lt;strong&gt;x&lt;/strong&gt; + b)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;where &lt;strong&gt;a&lt;/strong&gt; is a row vector and &lt;strong&gt;x&lt;/strong&gt; is a column vector.&amp;#160; This problem is equivalent to&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;minimize max{ &lt;strong&gt;a&lt;/strong&gt; * &lt;strong&gt;x&lt;/strong&gt; + b, - (&lt;strong&gt;a&lt;/strong&gt; * &lt;strong&gt;x&lt;/strong&gt; + b) }&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Or, using the trick from the previous post&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;minimize t&lt;/p&gt;    &lt;p&gt;subject to:&amp;#160; &lt;strong&gt;a&lt;/strong&gt; * &lt;strong&gt;x&lt;/strong&gt; + b&amp;#160; &amp;lt;= t&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/strong&gt;-(&lt;strong&gt;a&lt;/strong&gt; * &lt;strong&gt;x&lt;/strong&gt; + b) &amp;lt;= t&lt;/p&gt;&lt;/blockquote&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10019075" width="1" height="1"&gt;</description></item><item><title>Math Modeling Tricks:  Min-Max Problems</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/01/math-modeling-tricks-min-max-problems.aspx</link><pubDate>Tue, 01 Jun 2010 20:41:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10018483</guid><dc:creator>solverfoundation</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10018483</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/06/01/math-modeling-tricks-min-max-problems.aspx#comments</comments><description>&lt;p&gt;When modeling problems, one may come to a formulation that is not directly model-able using the Solver Foundation API, but that may be reformulated as a known Solver Foundation model type (LP, QP, CSP, etc).&amp;#160; Consider certain min-max problems, which with a little thought can become a linear program.&lt;/p&gt;  &lt;p&gt;In the current example, consider a min-max problem of the form&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;minimize max { &lt;strong&gt;a&lt;/strong&gt;_i *x + &lt;strong&gt;b&lt;/strong&gt;_i for all i }&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;where &lt;strong&gt;a&lt;/strong&gt;_i is a row of a matrix and &lt;strong&gt;b&lt;/strong&gt; is a vector.&amp;#160; This problem doesn’t look like anything that can be modeled using Solver Foundation.&amp;#160; But Solver Foundation can handle the problem when written in the mathematically equivalent form&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;minimize t&lt;/p&gt;    &lt;p&gt;subject to:&amp;#160; &lt;strong&gt;a&lt;/strong&gt;_i *x + &lt;strong&gt;b&lt;/strong&gt;_i &amp;lt;= t for all i&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;As an example, consider the toy problem where we try to determine the minimum of a one-dimensional non-linear convex function f(x).&amp;#160; We can do this by finding the minimum over a collection tangent lines, that is&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;minimize max { df(x_i)/dx *(x - x_i) + f(x_i) for all i }&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;or using our modeling trick&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;minimize t &lt;/p&gt;    &lt;p&gt;subject to:&amp;#160; df(x_i)/dx *(x - x_i) + f(x_i) &amp;lt;= t for all i&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;where the set i represents a sampling of points.&amp;#160; For a more concrete example, consider the problem f(x) = x + 1/x, which is convex for x &amp;gt; 0.&amp;#160; The minimum is at x = 1, where f(1) = 2.&amp;#160; The collection of tangent lines looks like&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-36-42-metablogapi/5344.envelope_5F00_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="envelope" border="0" alt="envelope" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-36-42-metablogapi/8715.envelope_5F00_thumb.jpg" width="423" height="334" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;where the horizontal axis represents x and the vertical axis represents f(x).&amp;#160; The code to find the minimum is below:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&lt;font color="#0000ff"&gt;static void&lt;/font&gt; Main() {        &lt;br /&gt;&amp;#160;&amp;#160; &lt;font color="#008080"&gt;SolverContext&lt;/font&gt; context = &lt;font color="#008080"&gt;SolverContext&lt;/font&gt;.GetContext();        &lt;br /&gt;&amp;#160;&amp;#160; &lt;font color="#008080"&gt;Model&lt;/font&gt; model = context.CreateModel(); &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160;&amp;#160; &lt;font color="#008080"&gt;Decision&lt;/font&gt; t = &lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#008080"&gt;Decision&lt;/font&gt;(&lt;font color="#008080"&gt;Domain&lt;/font&gt;.Real, &lt;font color="#ff0000"&gt;&lt;font color="#800000"&gt;&amp;quot;t&amp;quot;&lt;/font&gt;&lt;/font&gt;);        &lt;br /&gt;&amp;#160;&amp;#160; &lt;font color="#008080"&gt;Decision&lt;/font&gt; x = &lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#008080"&gt;Decision&lt;/font&gt;(&lt;font color="#008080"&gt;Domain&lt;/font&gt;.Real, &lt;font color="#ff0000"&gt;&lt;font color="#800000"&gt;&amp;quot;x&amp;quot;&lt;/font&gt;&lt;/font&gt;);        &lt;br /&gt;&amp;#160;&amp;#160; model.AddDecisions(t, x);        &lt;br /&gt;&amp;#160;&amp;#160; model.AddGoal(&lt;font color="#ff0000"&gt;&lt;font color="#800000"&gt;&amp;quot;goal&amp;quot;&lt;/font&gt;&lt;/font&gt;, &lt;font color="#008080"&gt;GoalKind&lt;/font&gt;.Minimize, t); &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160;&amp;#160; &lt;font color="#0000ff"&gt;int&lt;/font&gt; i = 0;        &lt;br /&gt;&amp;#160;&amp;#160; &lt;font color="#0000ff"&gt;for&lt;/font&gt; (&lt;font color="#0000ff"&gt;double&lt;/font&gt; x_i = .1; x_i &amp;lt;= 4; x_i = x_i + .01) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; model.AddConstraint(&lt;font color="#800000"&gt;&amp;quot;constraint_&amp;quot;&lt;/font&gt; + i++, derivative(x_i) * (x – x_i) + function(x_i) &amp;lt;= t);        &lt;br /&gt;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160;&amp;#160; &lt;font color="#008080"&gt;Solution&lt;/font&gt; solution = context.Solve();        &lt;br /&gt;&amp;#160;&amp;#160; &lt;font color="#008080"&gt;Report&lt;/font&gt; report = solution.GetReport();        &lt;br /&gt;&amp;#160;&amp;#160; &lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(report);&amp;#160; &lt;br /&gt; } &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160;&lt;font color="#0000ff"&gt;static double&lt;/font&gt; function(&lt;font color="#0000ff"&gt;double&lt;/font&gt; x) {        &lt;br /&gt;&amp;#160;&amp;#160; return x + 1 / x;        &lt;br /&gt; } &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160;&lt;font color="#0000ff"&gt;static double&lt;/font&gt; derivative(&lt;font color="#0000ff"&gt;double&lt;/font&gt; x) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return 1 - &lt;font color="#008080"&gt;Math&lt;/font&gt;.Pow(x, -2);        &lt;br /&gt; }&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The output is as follows:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2" face="Courier New"&gt;===Solver Foundation Service Report===       &lt;br /&gt;Date: 6/1/2010 10:58:26 AM        &lt;br /&gt;Version: Microsoft Solver Foundation 2.0.3.0 Enterprise Edition        &lt;br /&gt;Model Name: Default        &lt;br /&gt;Capabilities Applied: LP        &lt;br /&gt;Solve Time (ms): 316        &lt;br /&gt;Total Time (ms): 504        &lt;br /&gt;Solve Completion Status: Optimal        &lt;br /&gt;Solver Selected: Microsoft.SolverFoundation.Solvers.SimplexSolver        &lt;br /&gt;Directives: Microsoft.SolverFoundation.Services.Directive        &lt;br /&gt;Algorithm: Primal        &lt;br /&gt;Arithmetic: Hybrid        &lt;br /&gt;Variables: 2 -&amp;gt; 2 + 392        &lt;br /&gt;Rows: 392 -&amp;gt; 392        &lt;br /&gt;Nonzeros: 783        &lt;br /&gt;Eliminated Slack Variables: 0        &lt;br /&gt;Pricing (exact): SteepestEdge        &lt;br /&gt;Pricing (double): SteepestEdge        &lt;br /&gt;Basis: Slack        &lt;br /&gt;Pivot Count: 408        &lt;br /&gt;Phase 1 Pivots: 391 + 0        &lt;br /&gt;Phase 2 Pivots: 16 + 1        &lt;br /&gt;Factorings: 12 + 1        &lt;br /&gt;Degenerate Pivots: 0 (0.00 %)        &lt;br /&gt;Branches: 0        &lt;br /&gt;===Solution Details===        &lt;br /&gt;Goals:        &lt;br /&gt;goal: 2 &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font size="2" face="Courier New"&gt;Decisions:       &lt;br /&gt;t: 2        &lt;br /&gt;x: 0.994974874371864&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;As an additional point, note that while t = 2 is an expected result, x is not exactly the expected value of 1.&amp;#160; This is due to the fact that the problem is discretized with a finite series of tangent lines.&amp;#160; In fact, if you zoom in on tangent lines in the neighborhood of the minimum, given our discretization of a tangent line for every .1 in x, you will note that there are actually an infinite number of valid x values between x = .947368 and x = 1.047619.&lt;/p&gt;  &lt;p&gt;This code shows how we can use a mathematical trick for solving min-max problems.&amp;#160; However, for the particular example of minimizing a non-linear convex function, here are some reasons why it can’t be generally done:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;it may not be easy to know if the function is convex, or over which domain it’s convex.&lt;/li&gt;    &lt;li&gt;the method requires the user to know a neighborhood where the minimum can be found (in our case between x = .1 and x = 4), as well as a representation of the derivative&lt;/li&gt;    &lt;li&gt;we need enough points to create a realistic envelope.&amp;#160; In multiple dimensions, this could be expensive.&lt;/li&gt; &lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10018483" width="1" height="1"&gt;</description></item><item><title>Programmatically access report data</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/05/27/programmatically-access-report-data.aspx</link><pubDate>Thu, 27 May 2010 16:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10016410</guid><dc:creator>solverfoundation</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10016410</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/05/27/programmatically-access-report-data.aspx#comments</comments><description>&lt;p&gt;Solver Foundation Version 2.1 introduced a new API class called &lt;em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.solverfoundation.services.linearreport(VS.93).aspx"&gt;LinearReport&lt;/a&gt;&lt;/em&gt; that allows programmatic access of the report data. You can use this class to retreive sensitivity and infeasibility information.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s discuss with a simple model:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SolverContext context = SolverContext.GetContext(); &lt;/em&gt;&lt;i&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Model model = context.CreateModel(); &lt;/em&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //decisions &lt;/em&gt;&lt;i&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Decision xs = new Decision(Domain.RealNonnegative, "Number_of_small_chess_boards"); &lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Decision xl = new Decision(Domain.RealNonnegative, "Number_of_large_chess_boards"); &lt;/em&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; model.AddDecisions(xs, xl); &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //constraints &lt;/em&gt;&lt;i&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Constraint constraintBoxWood = model.AddConstraint("BoxWood", 1 * xs + 3 * xl &amp;lt;= 200); &lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Constraint constraintLathe = model.AddConstraint("Lathe", 3 * xs + 2 * xl &amp;lt;= 160); &lt;/em&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Goals &lt;/em&gt;&lt;i&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; model.AddGoal("Profit", GoalKind.Maximize, 5 * xs + 20 * xl); &lt;/em&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Solution sol = context.Solve(); &lt;/em&gt;&lt;i&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Report report = sol.GetReport();&lt;/em&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;To get the LinearReport, typecast report with LinearReport&lt;/p&gt;
&lt;p&gt;&lt;em&gt;LinearReport lpReport = report as LinearReport;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The following image shows some of the methods on the LinearReport that can used to retrieve sensitivity and infeasibility properties.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-36-42-metablogapi/1780.LinearReport_5F00_2.jpg"&gt;&lt;img height="237" width="394" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-36-42-metablogapi/1373.LinearReport_5F00_thumb.jpg" alt="LinearReport" border="0" title="LinearReport" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The following code demonstrates how to get the shadow prices of constraint &lt;em&gt;constraintBoxWood &lt;/em&gt;from the example:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;IEnumerable&amp;lt;KeyValuePair&amp;lt;string,Rational&amp;gt;&amp;gt; prices = lpReport.GetShadowPrices(constraintBoxWood);&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;or to get the shadow prices of all constraints:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;IEnumerable&amp;lt;KeyValuePair&amp;lt;string, Rational&amp;gt;&amp;gt; prices = lpReport.GetAllShadowPrices();&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Both of the above methods return pairs of each individual constraint&amp;rsquo;s name and its shadow price.&lt;/p&gt;
&lt;p&gt;Also when a model is infeasible, you can get the list of infeasible constraints:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;IEnumerable&amp;lt;string&amp;gt; infeasibleConstraints = lpReport.GetInfeasibilitySet();&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;GetInfeasibilitySet returns the list of constraint names that make the model infeasible&lt;/p&gt;
&lt;p&gt;For more examples, refer to DietProblem and ColumnGeneration samples (as part of the installation) that demonstrate how to access infeasibility and sensitivity data programmatically.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10016410" width="1" height="1"&gt;</description></item><item><title>Using Microsoft Solver Foundation with a WCF service application and .NET Framework 3.5</title><link>http://blogs.msdn.com/b/solverfoundation/archive/2010/05/20/using-microsoft-solver-foundation-with-a-wcf-service-application-and-net-framework-3-5.aspx</link><pubDate>Thu, 20 May 2010 21:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10013984</guid><dc:creator>solverfoundation</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/solverfoundation/rsscomments.aspx?WeblogPostID=10013984</wfw:commentRss><comments>http://blogs.msdn.com/b/solverfoundation/archive/2010/05/20/using-microsoft-solver-foundation-with-a-wcf-service-application-and-net-framework-3-5.aspx#comments</comments><description>&lt;p&gt;When using the&amp;nbsp;.NET Framework 3.5, a workaround is required to use a WCF service application with Solver Foundation. Without this workaround, the application may cause a configuration exception: "exePath must be specified when not running inside a stand alone exe". The workaround involves creating a web service to wrap the service application. NOTE: this workaround is not required for users of .NET Framework 4.&lt;/p&gt;
&lt;p&gt;For example, consider a WCF service application &lt;i&gt;OptimizationService&lt;/i&gt; that uses &lt;a href="http://www.solverfoundation.com/"&gt;MSF&lt;/a&gt; with a contract &lt;i&gt;Solve&lt;/i&gt;. Here is a code sample that illustrates this with a simple optimization problem:&lt;/p&gt;
&lt;p&gt;[OperationContract] &lt;/p&gt;
&lt;p&gt;public string Solve() { &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SolverContext context = SolverContext.GetContext();&lt;/p&gt;
&lt;p&gt;//decisions &lt;/p&gt;
&lt;p&gt;Decision xs = new Decision(Domain.RealNonnegative, "Number_of_small_chess_boards"); &lt;/p&gt;
&lt;p&gt;Decision xl = new Decision(Domain.RealNonnegative, "Number_of_large_chess_boards"); &lt;/p&gt;
&lt;p&gt;model.AddDecisions(xs, xl); &lt;/p&gt;
&lt;p&gt;//constraints &lt;/p&gt;
&lt;p&gt;Constraint constraintBoxWood = model.AddConstraint("BoxWood", 1 * xs + 3 * xl &amp;lt;= 200); &lt;/p&gt;
&lt;p&gt;Constraint constraintLathe = model.AddConstraint("Lathe", 3 * xs + 2 * xl &amp;lt;= 160); &lt;/p&gt;
&lt;p&gt;//Goals&lt;/p&gt;
&lt;p&gt;model.AddGoal("Profit", GoalKind.Maximize, 5 * xs + 20 * xl); &lt;/p&gt;
&lt;p&gt;Solution sol = context.Solve();GetContext(); &lt;/p&gt;
&lt;p&gt;Model model = context.CreateModel(); &lt;/p&gt;
&lt;p&gt;Report report = sol.GetReport(); &lt;/p&gt;
&lt;p&gt;return sol.GetReport().ToString();&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;} &lt;/p&gt;
&lt;p&gt;Now to use &lt;i&gt;OptimizationService&lt;/i&gt; from any application, create a ASP.Net web service &lt;i&gt;OptimizationWebService&lt;/i&gt; that defines a web method &lt;i&gt;Solve&lt;/i&gt;. The web method &lt;i&gt;Solve&lt;/i&gt; invokes the WCF service &lt;i&gt;OptimizationService&lt;/i&gt; defined above.&lt;/p&gt;
&lt;p&gt;[WebMethod] &lt;/p&gt;
&lt;p&gt;public string Solve() { &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;//Direct call to service &lt;/p&gt;
&lt;p&gt;OptimizationService service = new OptimizationService(); &lt;/p&gt;
&lt;p&gt;string value = service.Solve(); &lt;/p&gt;
&lt;p&gt;//or Call to a proxy client &lt;/p&gt;
&lt;p&gt;//OptimizationServiceClient client = new OptimizationServiceClient(); &lt;/p&gt;
&lt;p&gt;//string value = client.Solve(); &lt;/p&gt;
&lt;p&gt;return value; &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;} &lt;/p&gt;
&lt;p&gt;Now any client code can call the web service to access the WCF application service.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10013984" width="1" height="1"&gt;</description></item></channel></rss>