Retain the uncovered APIs, and replace with covered APIs with those chosed from High Quality Prompt.
(prompt1: Vec<String>, prompt2: Vec<String>)
| 95 | |
| 96 | /// Retain the uncovered APIs, and replace with covered APIs with those chosed from High Quality Prompt. |
| 97 | fn prompt_crossover(prompt1: Vec<String>, prompt2: Vec<String>) -> Vec<String> { |
| 98 | log::info!("Crossover {prompt1:#?} with {prompt2:#?}"); |
| 99 | if prompt1.len() >= prompt2.len() { |
| 100 | // crossover with lentgh of 3 |
| 101 | if prompt1.len() <= 3 { |
| 102 | return [prompt1, prompt2].concat(); |
| 103 | } |
| 104 | if prompt2.len() <= 3 { |
| 105 | let max_index = prompt1.len() - prompt2.len(); |
| 106 | let prompt2_len = prompt2.len(); |
| 107 | let index: usize = get_global_rng().gen::<usize>() % max_index; |
| 108 | crossover(prompt1, prompt2, index, 0, prompt2_len) |
| 109 | } else { |
| 110 | let max_index1 = prompt1.len() - 3; |
| 111 | let max_index2 = prompt2.len() - 3; |
| 112 | let index1 = get_global_rng().gen::<usize>() % max_index1; |
| 113 | let index2 = get_global_rng().gen::<usize>() % max_index2; |
| 114 | crossover(prompt1, prompt2, index1, index2, 3) |
| 115 | } |
| 116 | } else { |
| 117 | prompt_crossover(prompt2, prompt1) |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | pub fn mutate_prompt(prompt: &mut Prompt, schedule: &Schedule, deopt: &mut Deopt) { |
| 122 | let mutators = vec![ |
no test coverage detected