mopt: seed from state rand instead of current_nanos (#902)
This commit is contained in:
parent
948c94d695
commit
ff2971068f
@ -8,10 +8,7 @@ use core::{
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bolts::{
|
bolts::rands::{Rand, StdRand},
|
||||||
current_nanos,
|
|
||||||
rands::{Rand, StdRand},
|
|
||||||
},
|
|
||||||
corpus::Corpus,
|
corpus::Corpus,
|
||||||
mutators::{ComposedByMutations, MutationResult, Mutator, MutatorsTuple, ScheduledMutator},
|
mutators::{ComposedByMutations, MutationResult, Mutator, MutatorsTuple, ScheduledMutator},
|
||||||
state::{HasCorpus, HasMetadata, HasRand, HasSolutions},
|
state::{HasCorpus, HasMetadata, HasRand, HasSolutions},
|
||||||
@ -141,9 +138,9 @@ const PERIOD_PILOT_COEF: f64 = 5000.0;
|
|||||||
|
|
||||||
impl MOpt {
|
impl MOpt {
|
||||||
/// Creates a new [`struct@MOpt`] instance.
|
/// Creates a new [`struct@MOpt`] instance.
|
||||||
pub fn new(operator_num: usize, swarm_num: usize) -> Result<Self, Error> {
|
pub fn new(operator_num: usize, swarm_num: usize, rand_seed: u64) -> Result<Self, Error> {
|
||||||
let mut mopt = Self {
|
let mut mopt = Self {
|
||||||
rand: StdRand::with_seed(current_nanos()),
|
rand: StdRand::with_seed(rand_seed),
|
||||||
total_finds: 0,
|
total_finds: 0,
|
||||||
finds_until_last_swarm: 0,
|
finds_until_last_swarm: 0,
|
||||||
w_init: 0.9,
|
w_init: 0.9,
|
||||||
@ -537,7 +534,8 @@ where
|
|||||||
swarm_num: usize,
|
swarm_num: usize,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
if !state.has_metadata::<MOpt>() {
|
if !state.has_metadata::<MOpt>() {
|
||||||
state.add_metadata::<MOpt>(MOpt::new(mutations.len(), swarm_num)?);
|
let rand_seed = state.rand_mut().next();
|
||||||
|
state.add_metadata::<MOpt>(MOpt::new(mutations.len(), swarm_num, rand_seed)?);
|
||||||
}
|
}
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
mode: MOptMode::Pilotfuzzing,
|
mode: MOptMode::Pilotfuzzing,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user