Skip to content

Commit

Permalink
Merge branch 'feature/new-instructions' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
neoneye committed Aug 24, 2024
2 parents 3df7bc1 + 9b8a8d0 commit 2e7362c
Show file tree
Hide file tree
Showing 13 changed files with 980 additions and 47 deletions.
1 change: 1 addition & 0 deletions rust_project/loda-rust-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern crate log;

extern crate env_logger;

#[allow(unused_imports)]
#[macro_use]
extern crate assert_float_eq;

Expand Down
1 change: 1 addition & 0 deletions rust_project/loda-rust-cli/src/pattern/cluster_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ impl Clusters {
}
}

#[allow(dead_code)]
trait ConvertToString {
fn convert_to_string(&self) -> String;
}
Expand Down
2 changes: 2 additions & 0 deletions rust_project/loda-rust-cli/src/pattern/measure_similarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use loda_rust_core::parser::{Instruction, InstructionParameter, ParameterType};

pub enum ProgramSimilarity {
NotSimilar,

#[allow(dead_code)]
SimilarWithDifferentConstants(usize),
}

Expand Down
4 changes: 4 additions & 0 deletions rust_project/loda-rust-cli/src/subcommand_arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum SubcommandARCMode {
GenerateSolutionCSV,

/// Eval a single task with all the existing solutions.
#[allow(dead_code)]
EvalSingleTask { pattern: String },

/// The code being executed inside the docker image submitted for the `ARCathon` contest.
Expand All @@ -29,12 +30,15 @@ pub enum SubcommandARCMode {
/// where `name_of_solver` is one of:
/// - `lr` is logistic regression.
/// - `one` is `SolveOneColor`.
#[allow(dead_code)]
SolveWithSpecificSolver { name_of_solver: String },

/// Predict the output sizes for a single ARC task.
#[allow(dead_code)]
PredictOutputSizesForSingleTask { task_json_file: PathBuf },

/// Traverse the task json files, and assign a number of histogram comparisons.
#[allow(dead_code)]
MetadataHistogram { count: u16, seed: u64, task_json_directory: PathBuf },
}

Expand Down
39 changes: 25 additions & 14 deletions rust_project/loda-rust-core/src/execute/node_calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,31 @@ impl NodeCalc {

fn calc_with_semantics<S: Semantics>(&self, target: &BigInt, source: &BigInt) -> Result<BigInt, EvalError> {
match self.instruction_id {
InstructionId::Move => Ok(source.clone()),
InstructionId::Add => S::add(target, source),
InstructionId::Subtract => S::subtract(target, source),
InstructionId::Truncate => S::truncate(target, source),
InstructionId::Multiply => S::multiply(target, source),
InstructionId::Divide => S::divide(target, source),
InstructionId::DivideIf => S::divide_if(target, source),
InstructionId::Modulo => S::modulo(target, source),
InstructionId::Power => S::power(target, source),
InstructionId::GCD => S::gcd(target, source),
InstructionId::Binomial => S::binomial(target, source),
InstructionId::Compare => S::compare(target, source),
InstructionId::Min => S::min(target, source),
InstructionId::Max => S::max(target, source),
InstructionId::Move => Ok(source.clone()),
InstructionId::Add => S::add(target, source),
InstructionId::Subtract => S::subtract(target, source),
InstructionId::Truncate => S::truncate(target, source),
InstructionId::Multiply => S::multiply(target, source),
InstructionId::Divide => S::divide(target, source),
InstructionId::DivideIf => S::divide_if(target, source),
InstructionId::Modulo => S::modulo(target, source),
InstructionId::Power => S::power(target, source),
InstructionId::GCD => S::gcd(target, source),
InstructionId::Binomial => S::binomial(target, source),
InstructionId::Compare => S::compare(target, source),
InstructionId::Min => S::min(target, source),
InstructionId::Max => S::max(target, source),
InstructionId::Logarithm => S::logarithm(target, source),
InstructionId::NthRoot => S::nthroot(target, source),
InstructionId::DigitSum => S::digitsum(target, source),
InstructionId::DigitalRoot => S::digitalroot(target, source),
InstructionId::Equal => S::equal(target, source),
InstructionId::NotEqual => S::notequal(target, source),
InstructionId::LessOrEqual => S::lessorequal(target, source),
InstructionId::GreaterOrEqual => S::greaterorequal(target, source),
InstructionId::BitwiseAnd => S::bitwiseand(target, source),
InstructionId::BitwiseOr => S::bitwiseor(target, source),
InstructionId::BitwiseXor => S::bitwisexor(target, source),
_ => {
error!("unsupported instruction: {:?}", self.instruction_id);
return Err(EvalError::UnsupportedInstruction);
Expand Down
Loading

0 comments on commit 2e7362c

Please sign in to comment.