aboutsummaryrefslogtreecommitdiff
path: root/srchr/src
diff options
context:
space:
mode:
Diffstat (limited to 'srchr/src')
-rw-r--r--srchr/src/config.rs7
-rw-r--r--srchr/src/layout.rs53
2 files changed, 35 insertions, 25 deletions
diff --git a/srchr/src/config.rs b/srchr/src/config.rs
index f89aa18..76b9285 100644
--- a/srchr/src/config.rs
+++ b/srchr/src/config.rs
@@ -19,8 +19,8 @@ pub const NUM_PERSIST: usize = 8;
pub const MAX_NUM_TRANSPOSITIONS: usize = 6;
// Fitness parameters
-pub const STANDARD_DSFB_WEIGHT: f32 = 1.0 / 3.0;
-pub const INDEX_DSFB_WEIGHT: f32 = 1.0 / 3.0;
+pub const STANDARD_DSFB_WEIGHT: f32 = 1.0 / 16.0;
+pub const INDEX_DSFB_WEIGHT: f32 = 1.0 / 16.0;
pub const MIN_INDEX_USAGE_PERCENT: f32 = 0.12;
pub fn index_usage_fitness(index_perc: f32) -> f32 {
@@ -44,6 +44,9 @@ pub fn pinky_col_penalty(lesser_perc: f32, greater_perc: f32) -> f32 {
}
}
+// Pre-layout to layout
+pub const MINIMISE_LSB_INSTEAD_OF_OPTIMISING_BALANCE: bool = true;
+
// -----------------------------------------------------------------------------
// Do not change the following, the code makes assumptions about these
// -----------------------------------------------------------------------------
diff --git a/srchr/src/layout.rs b/srchr/src/layout.rs
index e6ac862..2b8cf05 100644
--- a/srchr/src/layout.rs
+++ b/srchr/src/layout.rs
@@ -167,31 +167,38 @@ impl Layout {
}
let w_index_columns = weight_function(&pl.index_columns, corpus);
- // Choose index order to minimise LSB (middle-index only) even though we
- // don't directly optimise for this parameter
- let mut lsbs = [0.0; 2];
- for option in [0, 1] {
- for left in [true, false] {
- let mind = if left { 2 } else { 7 };
- let side = if left { option } else { 1 - option };
- let m1 = keys[mind + 10 * 0] as u8;
- let m2 = keys[mind + 10 * 1] as u8;
- let m3 = keys[mind + 10 * 2] as u8;
- let i1 = w_index_columns[side].0[3];
- let i2 = w_index_columns[side].0[4];
- let i3 = w_index_columns[side].0[5];
- lsbs[option] += corpus.get_bigram_perc(m1, i1)
- + corpus.get_bigram_perc(m1, i2)
- + corpus.get_bigram_perc(m1, i3)
- + corpus.get_bigram_perc(m2, i1)
- + corpus.get_bigram_perc(m2, i2)
- + corpus.get_bigram_perc(m2, i3)
- + corpus.get_bigram_perc(m3, i1)
- + corpus.get_bigram_perc(m3, i2)
- + corpus.get_bigram_perc(m3, i3);
+
+ let (left_ind, right_ind);
+ if MINIMISE_LSB_INSTEAD_OF_OPTIMISING_BALANCE {
+ // Choose index order to minimise LSB (middle-index only) even though we
+ // don't directly optimise for this parameter
+ let mut lsbs = [0.0; 2];
+ for option in [0, 1] {
+ for left in [true, false] {
+ let mind = if left { 2 } else { 7 };
+ let side = if left { option } else { 1 - option };
+ let m1 = keys[mind + 10 * 0] as u8;
+ let m2 = keys[mind + 10 * 1] as u8;
+ let m3 = keys[mind + 10 * 2] as u8;
+ let i1 = w_index_columns[side].0[3];
+ let i2 = w_index_columns[side].0[4];
+ let i3 = w_index_columns[side].0[5];
+ lsbs[option] += corpus.get_bigram_perc(m1, i1)
+ + corpus.get_bigram_perc(m1, i2)
+ + corpus.get_bigram_perc(m1, i3)
+ + corpus.get_bigram_perc(m2, i1)
+ + corpus.get_bigram_perc(m2, i2)
+ + corpus.get_bigram_perc(m2, i3)
+ + corpus.get_bigram_perc(m3, i1)
+ + corpus.get_bigram_perc(m3, i2)
+ + corpus.get_bigram_perc(m3, i3);
+ }
}
+ (left_ind, right_ind) = if lsbs[0] < lsbs[1] { (0, 1) } else { (1, 0) }
+ } else {
+ (left_ind, right_ind) = if balance >= 0.0 { (0, 1) } else { (1, 0) }
}
- let (left_ind, right_ind) = if lsbs[0] < lsbs[1] { (0, 1) } else { (1, 0) };
+
for j in 0..3 {
keys[3 + j * ROW_LENGTH] = w_index_columns[left_ind].0[j] as char;
keys[6 + j * ROW_LENGTH] = w_index_columns[right_ind].0[j] as char;