{
  "id": 5813,
  "title": "Calling the simulator from C#",
  "url": "/competitions/flight2-milestone/discussion/5813",
  "author_name": "",
  "post_date": "2013-09-19T16:08:26.410Z",
  "votes": 1,
  "comment_count": 5,
  "views": 2351,
  "content": "<p>This is <em>almost</em> so convenient. I can include the FlightQuest.dll in my project and that lets me call the F# functions in &quot;Serialization.fs&quot;, and most of the other files, right from my C# code.</p>\n<p>But I can't seem to call &quot;loadMaps()&quot; or any of the other helpful-looking functions in &quot;Program.fs&quot;, so I need to translate them into C#. I confess, I'm having a lot of trouble with this translation. (In my defense, even the Xamarin debugger declares that some of the variables being passed around are &quot;in a zombie state.&quot;) In the long run, I'm hopeful I can make this work.</p>\n<p>But right now, I wish I had just two more functions that I could call from my C# code. The first would simply load everything, exactly as runSimulation.exe does on startup. The second would take one flight and one path (in some nice format like a string or an array please) and return the score after simulating just that one path for just that one flight.</p>\n<p>I actually have this equivalent functionality using &quot;System.Diagnostics.Process ()&quot; to interact with runSimulation.exe. It's fine for testing, but involves too much file IO for me to optimize 15K flights this way.&nbsp;</p>",
  "messages": [
    {
      "id": "31193",
      "postDate": "09/19/2013 16:08:26",
      "content": "<p>This is <em>almost</em> so convenient. I can include the FlightQuest.dll in my project and that lets me call the F# functions in &quot;Serialization.fs&quot;, and most of the other files, right from my C# code.</p>\n<p>But I can't seem to call &quot;loadMaps()&quot; or any of the other helpful-looking functions in &quot;Program.fs&quot;, so I need to translate them into C#. I confess, I'm having a lot of trouble with this translation. (In my defense, even the Xamarin debugger declares that some of the variables being passed around are &quot;in a zombie state.&quot;) In the long run, I'm hopeful I can make this work.</p>\n<p>But right now, I wish I had just two more functions that I could call from my C# code. The first would simply load everything, exactly as runSimulation.exe does on startup. The second would take one flight and one path (in some nice format like a string or an array please) and return the score after simulating just that one path for just that one flight.</p>\n<p>I actually have this equivalent functionality using &quot;System.Diagnostics.Process ()&quot; to interact with runSimulation.exe. It's fine for testing, but involves too much file IO for me to optimize 15K flights this way.&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "31196",
      "postDate": "09/19/2013 16:45:23",
      "content": "<p>[quote=glazed;31193]</p>\n<p>[It would be nice to have a function to] take one flight and one path (in some nice format like a string or an array please) and return the score after simulating just that one path for just that one flight.</p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>seconded.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "31222",
      "postDate": "09/19/2013 21:09:58",
      "content": "<p>[quote=Tanstaafl;31196]</p>\n<p>[quote=glazed;31193]</p>\n<p>[It would be nice to have a function to] take one flight and one path (in some nice format like a string or an array please) and return the score after simulating just that one path for just that one flight.</p>\n<p>[/quote]</p>\n<p>seconded.</p>\n<p>[/quote]</p>\n<p>Simulator.simulateFlight does exactly this. &nbsp;Take a look at simulateFlight<strong>s</strong> for how it's being used.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "31226",
      "postDate": "09/19/2013 22:48:24",
      "content": "<p>[quote=&#8469;ick &#8712; Sardo;31222]</p>\n<p>[quote=Tanstaafl;31196]</p>\n<p>[quote=glazed;31193]</p>\n<p>[It would be nice to have a function to] take one flight and one path (in some nice format like a string or an array please) and return the score after simulating just that one path for just that one flight.</p>\n<p>[/quote]</p>\n<p>seconded.</p>\n<p>[/quote]</p>\n<p>Simulator.simulateFlight does exactly this. &nbsp;Take a look at simulateFlight<strong>s</strong> for how it's being used.</p>\n<p>[/quote]</p>\n<p>Yes, it would be great to call simulateFlight(), if only I could figure out what to pass to it (and it's not something &quot;nice&quot;) and how to get the airport and other data read in first.</p>\n<p>I'm not finding fault here. I'm asking if there's a way around this obstacle. It's great that we can call these functions from another language. Could you please fix it so we don't have to translate a good chunk of optimized-to-run-in-parallel F# code to do so?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "31267",
      "postDate": "09/20/2013 17:55:23",
      "content": "<p>You don't need to translate the code - you just need it to be in a library. &nbsp;Create a new F# library, add a reference to FlightQuest, copy over the desired methods, make modifications to fit your needs, and then reference this project from your C# project.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "31281",
      "postDate": "09/20/2013 23:12:58",
      "content": "<p>[quote=&#8469;ick &#8712; Sardo;31267]</p>\n<p>You don't need to translate the code - you just need it to be in a library. &nbsp;Create a new F# library, add a reference to FlightQuest, copy over the desired methods, make modifications to fit your needs, and then reference this project from your C# project.</p>\n<p>[/quote]</p>\n<p>Thanks. I'll try that.</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 31196,
      "author_name": "tanstaafl",
      "author_url": "",
      "post_date": "09/19/2013 16:45:23",
      "content": "<p>[quote=glazed;31193]</p>\n<p>[It would be nice to have a function to] take one flight and one path (in some nice format like a string or an array please) and return the score after simulating just that one path for just that one flight.</p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>seconded.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 31222,
      "author_name": "nicksardo",
      "author_url": "",
      "post_date": "09/19/2013 21:09:58",
      "content": "<p>[quote=Tanstaafl;31196]</p>\n<p>[quote=glazed;31193]</p>\n<p>[It would be nice to have a function to] take one flight and one path (in some nice format like a string or an array please) and return the score after simulating just that one path for just that one flight.</p>\n<p>[/quote]</p>\n<p>seconded.</p>\n<p>[/quote]</p>\n<p>Simulator.simulateFlight does exactly this. &nbsp;Take a look at simulateFlight<strong>s</strong> for how it's being used.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 31226,
      "author_name": "glazed",
      "author_url": "",
      "post_date": "09/19/2013 22:48:24",
      "content": "<p>[quote=&#8469;ick &#8712; Sardo;31222]</p>\n<p>[quote=Tanstaafl;31196]</p>\n<p>[quote=glazed;31193]</p>\n<p>[It would be nice to have a function to] take one flight and one path (in some nice format like a string or an array please) and return the score after simulating just that one path for just that one flight.</p>\n<p>[/quote]</p>\n<p>seconded.</p>\n<p>[/quote]</p>\n<p>Simulator.simulateFlight does exactly this. &nbsp;Take a look at simulateFlight<strong>s</strong> for how it's being used.</p>\n<p>[/quote]</p>\n<p>Yes, it would be great to call simulateFlight(), if only I could figure out what to pass to it (and it's not something &quot;nice&quot;) and how to get the airport and other data read in first.</p>\n<p>I'm not finding fault here. I'm asking if there's a way around this obstacle. It's great that we can call these functions from another language. Could you please fix it so we don't have to translate a good chunk of optimized-to-run-in-parallel F# code to do so?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 31267,
      "author_name": "nicksardo",
      "author_url": "",
      "post_date": "09/20/2013 17:55:23",
      "content": "<p>You don't need to translate the code - you just need it to be in a library. &nbsp;Create a new F# library, add a reference to FlightQuest, copy over the desired methods, make modifications to fit your needs, and then reference this project from your C# project.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 31281,
      "author_name": "glazed",
      "author_url": "",
      "post_date": "09/20/2013 23:12:58",
      "content": "<p>[quote=&#8469;ick &#8712; Sardo;31267]</p>\n<p>You don't need to translate the code - you just need it to be in a library. &nbsp;Create a new F# library, add a reference to FlightQuest, copy over the desired methods, make modifications to fit your needs, and then reference this project from your C# project.</p>\n<p>[/quote]</p>\n<p>Thanks. I'll try that.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "31193": "",
    "31196": "",
    "31222": "",
    "31226": "",
    "31267": "",
    "31281": ""
  },
  "source": "meta"
}