//! Updates the current infoemation (configuration). /*! * \param solution Solution (configuration) */ public void updateConfiguration(Solution new_solution) { T_Changes changes = Solution.getChanges(configuration, new_solution); if (changes.Dimension > 0) { current_cost += relative_cost(new_solution, changes, true); configuration = new_solution.GetConfByCopy; } }
//! Computes the cost of a solution relative to the current. /*! * \param solution Solution (configuration) * \param change Performed changes w.r.t. the current configuration * \param updating Whether the internal information has to be updated * \return The relative cost */ public int relative_cost(Solution new_solution, T_Changes change, bool updating) { int cost = 0; int pos, new_value, w, g, j; int start_position_group_for_change, end_group_for_change; int current_player_at_pos, partner_current_group, partner_new_group; for (int i = 0; i < change.Dimension; i++) { pos = change.Positions[i]; new_value = change.NewValues[i]; w = pos / TP; g = (pos % TP) / players; start_position_group_for_change = w * TP + g * players; end_group_for_change = w * TP + (g + 1) * players; for (j = start_position_group_for_change; j < end_group_for_change; j++) { if (j != pos) { current_player_at_pos = configuration[pos]; partner_current_group = configuration[j]; partner_new_group = new_solution[j]; if (updating) { cc_occurrences.remove_connection(current_player_at_pos, partner_current_group); cost += (cc_occurrences.are_connected(current_player_at_pos, partner_current_group)) ? -2 : 0; } else { cost += (cc_occurrences.would_be_disconnected(current_player_at_pos, partner_current_group)) ? -2 : 0; } //cost += cc_occurrences.remove_connection(current_player_at_pos, partner_current_group, updating); //cost += cc_occurrences.add_connection(new_value, partner_new_group, updating); if (updating) { cc_occurrences.add_connection(new_value, partner_new_group); } cost += 2; } } } return(cost); }
//! Computes the cost of a solution relative to the current. /*! * \param solution Solution (configuration) * \param change Performed changes w.r.t. the current configuration * \return The relative cost */ public int relativeSolutionCost(Solution new_solution, T_Changes _changes) { return(current_cost + relative_cost(new_solution, _changes, false)); }
//! Computes the cost of a solution relative to the current. /*! * \param solution Solution (configuration) * \return The relative cost */ public int relativeSolutionCost(Solution new_solution) { T_Changes changes = Solution.getChanges(configuration, new_solution); return(relativeSolutionCost(new_solution, changes)); }
//! Computes the cost of a configuration relative to the current configuration. /*! * \param new_solution A configuration (solution). * \param _change The performed changes w.r.t the current configuration * \return Cost of the given configuration. */ public int relativeSolutionCost(Solution new_solution, T_Changes changes) { return(relative_cost_strategy.relativeSolutionCost(new_solution, changes)); }