Skip to content

Commit 076e13d

Browse files
committed
Merge branch 'feature/iteration64' into develop
2 parents c5993f7 + ff8b7b9 commit 076e13d

File tree

10 files changed

+196
-47
lines changed

10 files changed

+196
-47
lines changed

rust_project/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust_project/arc-competition/payload/.loda-rust/analytics-arc/analytics_log.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ optimize: 0, dontoptimize: 1, optimize/total: 0.0%
3232
AnalyzeProgramModified
3333
timestamps: 88
3434

35-
subcommand_analytics finished, elapsed: 21 ms
35+
subcommand_analytics finished, elapsed: 24 ms
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2023-11-25T18:24:46Z
1+
2023-11-26T21:00:17Z

rust_project/loda-rust-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "loda-rust-cli"
3-
version = "2023.11.25"
3+
version = "2023.11.26"
44
authors = ["Simon Strandgaard <[email protected]>"]
55
description = "Command line interface for LODA Rust"
66
repository = "https://github.com/loda-lang/loda-rust"

rust_project/loda-rust-cli/src/arc/arc_work_model.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub struct Input {
106106

107107
// Future experiments to do.
108108
// least_popular_intersection_color
109+
// density of each color, if it's noise the density is low, if it's a solid cluster the density is high.
109110
//
110111
// Resolving these properties is similar to a package manager, a DAG (directed acyclic graph).
111112
// One property may depend on another property that depends on a third property.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
use super::{Image, ImagePadding, convolution3x3, ImageHistogram, Histogram};
2+
use anyhow::bail;
3+
4+
pub struct MeasureDensity {
5+
pub density_any_direction: Image,
6+
}
7+
8+
impl MeasureDensity {
9+
pub fn analyze(image: &Image) -> anyhow::Result<Self> {
10+
if image.is_empty() {
11+
bail!("image is empty. Must be 1x1 or larger");
12+
}
13+
let padding: Image = image.padding_with_color(1, 255)?;
14+
let density: Image = convolution3x3(&padding, conv3x3_measure_density_any_direction)?;
15+
let instance = Self {
16+
density_any_direction: density,
17+
};
18+
Ok(instance)
19+
}
20+
}
21+
22+
fn conv3x3_measure_density_any_direction(image: &Image) -> anyhow::Result<u8> {
23+
let histogram: Histogram = image.histogram_all();
24+
let center: u8 = image.get(1, 1).unwrap_or(255);
25+
let count: u32 = histogram.get(center).min(9).max(1) - 1;
26+
Ok(count as u8)
27+
}
28+
29+
#[cfg(test)]
30+
mod tests {
31+
use super::*;
32+
use crate::arc::ImageTryCreate;
33+
34+
#[test]
35+
fn test_10000_density_any_direction() {
36+
// Arrange
37+
let pixels: Vec<u8> = vec![
38+
5, 3, 3, 3,
39+
3, 3, 3, 3,
40+
5, 5, 3, 3,
41+
3, 5, 3, 3,
42+
];
43+
let input: Image = Image::try_create(4, 4, pixels).expect("image");
44+
45+
// Act
46+
let actual: MeasureDensity = MeasureDensity::analyze(&input).expect("image");
47+
48+
// Assert
49+
let expected_pixels: Vec<u8> = vec![
50+
0, 4, 5, 3,
51+
2, 5, 7, 5,
52+
2, 2, 6, 5,
53+
0, 2, 3, 3,
54+
];
55+
let expected: Image = Image::try_create(4, 4, expected_pixels).expect("image");
56+
assert_eq!(actual.density_any_direction, expected);
57+
}
58+
}

rust_project/loda-rust-cli/src/arc/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ mod label;
116116
mod landmark_single_pixel;
117117
mod largest_interior_rectangle;
118118
mod linespan;
119+
mod measure_density;
119120
mod ngram;
120121
mod number_to_image;
121122
mod object_with_different_color;
@@ -265,6 +266,7 @@ pub use label::{ActionLabel, ActionLabelSet, GridLabel, ImageCorner, ImageEdge,
265266
pub use landmark_single_pixel::LandmarkSinglePixel;
266267
pub use largest_interior_rectangle::LargestInteriorRectangle;
267268
pub use linespan::{LineSpan, LineSpanDirection, LineSpanMode};
269+
pub use measure_density::MeasureDensity;
268270
pub use ngram::{ImageNgram, RecordBigram, RecordTrigram};
269271
pub use number_to_image::NumberToImage;
270272
pub use object_with_different_color::ObjectWithDifferentColor;

rust_project/loda-rust-cli/src/arc/solve_logisticregression.rs

Lines changed: 120 additions & 38 deletions
Large diffs are not rendered by default.

rust_project/loda-rust-cli/src/arc/solve_one_color.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
//! Solve tasks that outputs a single color.
22
//!
3+
//! Solves zero of the hidden ARC tasks.
4+
//!
35
//! The ARC 1 dataset contains 800 tasks, where 17 of the tasks outputs a single color.
46
//! 1190e5a7, 1a2e2828, 239be575, 23b5c85d, 27a28665, 3194b014, 445eab21, 44f52bb0, 5582e5ca, 642d658d,
57
//! 7039b2d7, 8597cfd7, b9b7f026, d631b094, d9fac9be, de1cd16c, e872b94a,
68
//!
7-
//! This solver is able to solve 16 of the 17 tasks.
8-
//! Where 10 is solved with some confidence.
9-
//! Where 6 of them is solved as a happy accident.
10-
//! Where 1 task is not solved b9b7f026, because it has more than 4 colors to choose from, and chooses the wrong color.
9+
//! This solver is able to solve 14 of the 17 tasks.
10+
//! Where 9 is solved with some confidence.
11+
//! Where 5 of them is solved as a happy accident.
12+
//! Where 3 tasks is not solved 1a2e2828, 27a28665, b9b7f026, because it has more than 4 colors to choose from, and chooses the wrong color.
1113
//!
1214
//! Weakness:
1315
//! When there are 4 or more colors to choose from, then it doesn't do any prediction, and takes the 3 first colors.
@@ -513,6 +515,10 @@ impl SolveOneColor {
513515
// Assign a low confidence score to these predictions, so they are ranked lower than other high confidence predictions.
514516
// Rule out the noise color, grid color, most dense colors.
515517
debug!("low confidence: task: {} - test_index: {} - available_colors: {:?}", task.id, test_index, the_colors);
518+
// Taking the initial 3 colors doesn't solve any of the hidden ARC tasks.
519+
// Here is a crappy 2nd guess. By reversing the_colors.
520+
the_colors.reverse();
521+
the_colors.truncate(3);
516522
}
517523
}
518524
Ok(the_colors)

rust_project/loda-rust-cli/src/arc/traverse_programs_and_models.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ impl TraverseProgramsAndModels {
16031603
let resume_from_last_snapshot = false;
16041604

16051605
// Solve tasks that outputs a single color.
1606-
// Not yet tried on the hidden ARC dataset, so I don't know if this doesn't solves any tasks.
1606+
// On the hidden ARC dataset, this doesn't solve any tasks.
16071607
let try_solve_one_color = true;
16081608

16091609
// Solve `splitview` like tasks.

0 commit comments

Comments
 (0)