No puedo ejecutar una solución con parámetros de enrutamiento porque el método no acepta los RoutingSearchParameters predeterminados porque la instancia está vacía (cada campo se establece en 0).

Así es como estoy creando la instancia:

// final var p = RoutingSearchParameters.newBuilder().build(); Both don't work
final var p = RoutingSearchParameters.getDefaultInstance();
final var s = routing.solveWithParameters(p);

Aquí está el error (ocurre para cada campo):

E0717 20:27:26.682358  6108 routing.cc:1886] Invalid RoutingSearchParameters: Invalid cheapest_insertion_first_solution_neighbors_ratio: 0

¿Hay alguna forma de resolverlo sin configurar manualmente cada campo?

0
Hugo Sartori 18 jul. 2020 a las 02:43

2 respuestas

La mejor respuesta

Como señala un comentario: la forma correcta de crear una instancia de la clase RoutingSearchParameters es importando com.google.ortools.constraintsolver.main y luego utilizando el método main.defaultRoutingSearchParameters().

0
Hugo Sartori 23 jul. 2020 a las 14:25

Todos los parámetros predeterminados son visibles aquí:

https://github.com/google/or-tools/blob/45770b833997f827d322e929b1ed4781c4e60d44/ortools/constraint_solver/routing_parameters.cc#L45

      "first_solution_strategy: AUTOMATIC "
  "use_unfiltered_first_solution_strategy: false "
  "savings_neighbors_ratio: 1 "
  "savings_max_memory_usage_bytes: 6e9 "
  "savings_add_reverse_arcs: false "
  "savings_arc_coefficient: 1 "
  "savings_parallel_routes: false "
  "cheapest_insertion_farthest_seeds_ratio: 0 "
  "cheapest_insertion_first_solution_neighbors_ratio: 1 "
  "cheapest_insertion_ls_operator_neighbors_ratio: 1 "
  "local_search_operators {"
  "  use_relocate: BOOL_TRUE"
  "  use_relocate_pair: BOOL_TRUE"
  "  use_light_relocate_pair: BOOL_TRUE"
  "  use_relocate_subtrip: BOOL_TRUE"
  "  use_relocate_neighbors: BOOL_FALSE"
  "  use_exchange: BOOL_TRUE"
  "  use_exchange_pair: BOOL_TRUE"
  "  use_exchange_subtrip: BOOL_TRUE"
  "  use_cross: BOOL_TRUE"
  "  use_cross_exchange: BOOL_FALSE"
  "  use_relocate_expensive_chain: BOOL_TRUE"
  "  use_two_opt: BOOL_TRUE"
  "  use_or_opt: BOOL_TRUE"
  "  use_lin_kernighan: BOOL_TRUE"
  "  use_tsp_opt: BOOL_FALSE"
  "  use_make_active: BOOL_TRUE"
  "  use_relocate_and_make_active: BOOL_FALSE"  // costly if true by default
  "  use_make_inactive: BOOL_TRUE"
  "  use_make_chain_inactive: BOOL_FALSE"
  "  use_swap_active: BOOL_TRUE"
  "  use_extended_swap_active: BOOL_FALSE"
  "  use_node_pair_swap_active: BOOL_TRUE"
  "  use_path_lns: BOOL_FALSE"
  "  use_full_path_lns: BOOL_FALSE"
  "  use_tsp_lns: BOOL_FALSE"
  "  use_inactive_lns: BOOL_FALSE"
  "  use_global_cheapest_insertion_path_lns: BOOL_TRUE"
  "  use_local_cheapest_insertion_path_lns: BOOL_TRUE"
  "  use_global_cheapest_insertion_expensive_chain_lns: BOOL_FALSE"
  "  use_local_cheapest_insertion_expensive_chain_lns: BOOL_FALSE"
  "}"
  "relocate_expensive_chain_num_arcs_to_consider: 4 "
  "heuristic_expensive_chain_lns_num_arcs_to_consider: 4 "
  "local_search_metaheuristic: AUTOMATIC "
  "guided_local_search_lambda_coefficient: 0.1 "
  "use_depth_first_search: false "
  "use_cp: BOOL_TRUE "
  "use_cp_sat: BOOL_FALSE "
  "continuous_scheduling_solver: GLOP "
  "mixed_integer_scheduling_solver: CP_SAT "
  "optimization_step: 0.0 "
  "number_of_solutions_to_collect: 1 "
  // No "time_limit" by default.
  "solution_limit: 0x7fffffffffffffff "             // kint64max
  "lns_time_limit: { seconds:0 nanos:100000000 } "  // 0.1s
  "use_full_propagation: false "
  "log_search: false "
  "log_cost_scaling_factor: 1.0 "
  "log_cost_offset: 0.0";
1
Laurent Perron 18 jul. 2020 a las 10:38