Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"cells": [
{
Expand Down Expand Up @@ -129,7 +129,6 @@
" The below script needs to be able to find the current output cell; this is an easy method to get it.\r\n",
" </div>\r\n",
" <script type='text/javascript'>\r\n",

" function timeout(ms, promise) {\r\n",
" return new Promise(function (resolve, reject) {\r\n",
" setTimeout(function () {\r\n",
Expand All @@ -139,10 +138,7 @@
" })\r\n",
" }\r\n",
"\r\n",


"\r\n",

"\r\n",
" if (!rootUrl.endsWith('/')) {\r\n",
" rootUrl = `${rootUrl}/`;\r\n",
Expand All @@ -157,7 +153,6 @@
" headers: {\r\n",
" 'Content-Type': 'text/plain'\r\n",
" },\r\n",

" }));\r\n",
"\r\n",
" if (response.status == 200) {\r\n",
Expand All @@ -169,8 +164,6 @@
" }\r\n",
"}\r\n",
"\r\n",


" .then((root) => {\r\n",
" // use probing to find host url and api resources\r\n",
" // load interactive helpers and language services\r\n",
Expand Down Expand Up @@ -219,13 +212,11 @@
" \r\n",
" \r\n",
" require_script.onload = function() {\r\n",

" };\r\n",
"\r\n",
" document.getElementsByTagName('head')[0].appendChild(require_script);\r\n",
"}\r\n",
"else {\r\n",

"}\r\n",
"\r\n",
" </script>\r\n",
Expand Down Expand Up @@ -2002,7 +1993,10 @@
" var exploredOrder = new List<string>();\n",
"\n",
" // DFS recursif : retourne (solution, prochaine borne).\n",
" (Node sol, double nextBound) Dfs(Node node, double curBound) {\n",
" // depth = profondeur recursive (= memoire de pile reelle d'IDA*).\n",
" int maxDepth = 0;\n",
" (Node sol, double nextBound) Dfs(Node node, double curBound, int depth) {\n",
" if (depth > maxDepth) maxDepth = depth;\n",
" double f = node.PathCost + h(node.State);\n",
" if (f > curBound) return (null, f); // coupure\n",
" if (problem.GoalTest(node.State)) return (node, curBound);\n",
Expand All @@ -2011,7 +2005,7 @@
" double minNext = double.PositiveInfinity;\n",
" foreach (var child in node.Expand(problem)) {\n",
" totalGenerated++;\n",
" var (sol, childBound) = Dfs(child, curBound);\n",
" var (sol, childBound) = Dfs(child, curBound, depth + 1);\n",
" if (sol != null) return (sol, curBound);\n",
" if (childBound < minNext) minNext = childBound;\n",
" }\n",
Expand All @@ -2023,16 +2017,18 @@
" while (iterations < maxIters) {\n",
" iterations++;\n",
" if (verbose) Console.WriteLine($\" Iteration {iterations}: f-limit = {bound:F0}\");\n",
" var (result, newBound) = Dfs(root, bound);\n",
" var (result, newBound) = Dfs(root, bound, 0);\n",
" if (result != null) {\n",
" sw.Stop();\n",
" return new SearchResult(\"IDA*\", result, totalExpanded, totalGenerated, iterations, sw.Elapsed.TotalMilliseconds, exploredOrder);\n",
" // 5eme slot = max_frontier_size. Pour IDA* la frontiere n'existe pas,\n",
" // on y passe la profondeur recursive max (= memoire de pile reelle, O(bd)).\n",
" return new SearchResult(\"IDA*\", result, totalExpanded, totalGenerated, maxDepth, sw.Elapsed.TotalMilliseconds, exploredOrder);\n",
" }\n",
" if (double.IsInfinity(newBound)) break; // espace epuise, pas de solution\n",
" bound = newBound;\n",
" }\n",
" sw.Stop();\n",
" return new SearchResult(\"IDA*\", null, totalExpanded, totalGenerated, iterations, sw.Elapsed.TotalMilliseconds, exploredOrder);\n",
" return new SearchResult(\"IDA*\", null, totalExpanded, totalGenerated, maxDepth, sw.Elapsed.TotalMilliseconds, exploredOrder);\n",
"}\n",
"\n",
"Console.WriteLine(\"Algorithme IDA* implemente.\");"
Expand Down
Loading
Loading