50 likes | 167 Vues
Appendix C. 1. Min-Conflict Hill Climbing 2. Min-Conflict Random Walk. Min-conflict Hill Climbing. procedure GenerateLocalMoves(s, TotalMoves) begin M’ , BestCost f(s) choose randomly a variable v in conflict
E N D
Appendix C 1. Min-Conflict Hill Climbing 2. Min-Conflict Random Walk
Min-conflict Hill Climbing procedure GenerateLocalMoves(s, TotalMoves) begin M’ , BestCost f(s) choose randomly a variable v in conflict choose a value d for v (d dcurr) that minimizes the number of conflicts for v. m {v, d} if f(sm) BestCost then // accepts improving moves and sideways moves begin if f(sm) < BestCost then begin BestCost f(sm); M’ end M’ M’ m end if M’ = then TotalMoves MaxMoves return M’ end
Notes • How to create initial solution in MCHC • First, randomly assign a domain value to the first variable, then assign each of subsequent variable a domain value that causes the least number of conflicts with previously assigned variables. (greedy preprocessing phase) • However, MCHC does not have the mechanism to escape local minima.
Min-Conflict Random Walk begin generate randomly an initial solution s n_iter := 0; n_moves := 0 while f(x) > max_cost and n_moves < max_moves do if p > random number between 0 and 1 then choose randomly a variable V in conflict choose randomly a value v’ for V else choose randomly a variable V in conflict choose a value v’ for V that minimizes the number of conflicts for v. (the current value is chosen only if all the other values increase the number of violated constraints.) if v’ is different from the current value of V then assign v’ to V n_moves := n_moves + 1 n_iter := n_iter + 1 endwhile output(s) end
Notes • The algorithm MCRW is controlled by the random probability p. • An iteration leading a new solution different from the current one is called a move. • MCRW may have many iterations that do not lead to a move. An improvement can be as follows: • If an iteration fails to lead to a move for a conflicting variable V, V will not be considered for the next iterations until a move is effectively carried out.