public override void Solve() { var pparser = new Pparser(FpatIn); int n, l; pparser.Fetch(out n, out l); var rgnode = pparser.FetchN <string>(n); rgnode.Insert(0, "X"); var model = new RoutingModel(n, 1); model.SetFirstSolutionStrategy(RoutingModel.ROUTING_GLOBAL_CHEAPEST_ARC); //model.SetMetaheuristic(RoutingModel.ROUTING_TABU_SEARCH); model.SetCost(new NodeEval(rgnode.ToArray())); model.SetDepot(0); for (int i = 0; i < n; i++) { var varI = model.NextVar(i); for (int j = 0; j < n; j++) { if (i == j) { continue; } if (!NodeEval.FMatch(rgnode[i], rgnode[j])) { varI.RemoveValue(j); } } } Console.WriteLine("solving"); Assignment solution = model.Solve(); model.UpdateTimeLimit(1000 * 60 * 3); if (solution != null) { // Solution cost. Console.WriteLine("Cost = {0}", solution.ObjectiveValue()); for (var inode = (int)model.Start(0); !model.IsEnd(inode); inode = (int)solution.Value(model.NextVar(inode))) { Console.WriteLine(rgnode[inode]); } Console.WriteLine("0"); } }