Traveling Salesman Problems using Solver Foundation: C# code

This post has been updated. Click here to read it.

Comments (7)

  1. Tekin Kunt says:

    Hi Nathan,

    Thanks for posting this code.  I  have been playing with the MSF and it is nice to see many pieces in action here.  In an earlier posting, you have mentioned that you could use either "rank" or "assign" to display the results, but you chose to use "assign" to demonstrate some more LINQ capabilities.  However I am not getting the expected results with using "assign" alone.  Do we need to sort it somehow?  Thanks!


  2. Nate Brixius says:

    Hi Tekin,

    Can you elaborate? In the last part of this sample I am doing a "select" from assign to print out the tour.  Assign[i, j] == 1 means that the arc i -> j is in the tour.

  3. Tekin Kunt says:

    Hi Nathan,

    Select statement returns j's for active arcs.  When you print them out with "->" I assumed that the order represented the route taken.  It is not the case however.  You can confirm that by printing the full report and construct the route from it.  Thanks.

  4. John Bowers says:

    I am getting an error when putting this into Microsoft Visual Studio 2010.

    the line:

    "using Microsoft.SolverFoundation.Services;"


    the name space does not exist and asks if I am missing an assembly reference.

  5. Maria Islam says:

    Thank you So Match for your Post…But there's one Error is :

        "   Error 1 The type or namespace name 'SolverFoundation' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) "

    i search for it on "References">>Add  Reference>>.Net or Com    but i didn't find it this "SolverFoundation"….

    What should i do ? Please Help me!.

    Thank You Again.

  6. Nate Brixius says:

    Hi Maria, you need to download and install the Express version of Solver Foundation from  Make sure your project is .Net 4, NOT .Net 4 Client Profile. Otherwise you will not see Solver Foundation listed as a .Net reference.

  7. Nathalie White says:

    Hi, creat code, works fine for me!

    Iam new in modelling, and iam asking my self, if it is possible to add a constraint which defines that a city has to be "entered" (assigned) after a spefic distance.

    thx Nathalie