title: Microsoft Solver Foundation and F#
body: <p>I'm trying to convert this <a href="https://msdn.microsoft.com/en-us/library/ff759370%28v=vs.93%29.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow">MS Solver Foundation example</a> from C# to F#, but constantly running into problems with type conversions, in particular in section 5, where C# accepts implicit conversion from double to Rational, something F# does not accept - any ideas how to resolve? The Rational type in itself is a puzzle for me as seems virtually impossible to initialize apart from setting it to the predefined Rational.One or Rational.Zero. Any ideas? See a minimalist down-scaled version below (without using any arrays or anything).</p>
  
  <pre><code>let main argv = 
  
  printfn "%A" argv
  Console.WriteLine("\nBegin Solver demo\n")
  let mean = 1.0
  let solver = new InteriorPointSolver()
  let allocation = ref 0
  solver.AddVariable("MSFT", allocation) |&gt; ignore
  solver.SetBounds(!allocation, Rational.Zero, Rational.One)
  
  let expRet = ref 0
  solver.AddRow("expRet", expRet) |&gt; ignore
  solver.SetBounds(!expRet, Rational.Zero, Rational.PositiveInfinity)
  
  let unity = ref 0
  solver.AddRow("Investments sum to one", unity) |&gt; ignore
  solver.SetBounds(!unity, Rational.One, Rational.One)
  
  solver.SetCoefficient(!expRet, !allocation, Rational.)
  solver.SetCoefficient(!unity, !allocation, Rational.One);
  
  Console.WriteLine("\nEnd Solver demo\n")
  Console.ReadLine() |&gt; ignore
  0 // return an integer exit code
  </code></pre>