Skip to content

Unaimend/Histafinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Histafinder

Histafinder is a Rust application that uses a Satisfiability (SAT) solver to determine which ingredients in a list of meals are likely to cause a reaction. It's designed to help users with dietary restrictions or allergies identify potential trigger ingredients based on their meal logs.


How It Works

The program takes a structured list of meals and ingredients, along with an indicator of whether a reaction occurred after consuming each meal. It then translates this problem into a SAT problem.

  • Each unique ingredient is represented by a boolean variable.
  • A variable being true means the ingredient is a potential allergen.
  • A variable being false means the ingredient is not an allergen.

The program constructs a Conjunctive Normal Form (CNF) formula with clauses that represent the following logic:

  • For meals where a reaction occurred: At least one of the ingredients in that meal must be an allergen. This is represented by a clause like (ingredient1 ∨ ingredient2 ∨ ... ).
  • For meals where no reaction occurred: None of the ingredients in that meal can be an allergen. This is represented by a set of clauses, one for each ingredient, like (¬ingredient1) ∧ (¬ingredient2) ∧ ....

The SAT solver then finds a valid assignment of true or false to each ingredient variable that satisfies all the clauses. The ingredients assigned true are the potential allergens.


Usage

Prerequisites

  • Rust programming language: You can install it from rustup.rs.

Running the Application

  1. Clone the repository:

    git clone https://github.com/Unaimend/Histafinder
    cd Histafinder
  2. Create an input file eg. file.txt : This file should contain your meal data in the following format:

    Meal 1: ingredient1, ingredient2, ingredient3 | 1
    Meal 2: ingredient4, ingredient5 | 0
    Meal 3: ingredient1, ingredient4, ingredient6 | 1
    Meal 4: ingredient2, ingredient5, ingredient7 | 0
    
    • Meal 1: The name of the meal.
    • ingredient1, ingredient2, ...: A comma-separated list of ingredients.
    • | 1 or | 0: A 1 indicates a reaction occurred; a 0 indicates no reaction.
  3. Run the program:

    cargo run -- file.txt

The program will print the identified allergens to the console.


This README was written by ChatGPT, the code was not.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages