Projects
My Projects
Here are some of the projects I have worked on. Each project’s description and README are included below.
NP‑Complete Solver LLM
This project is a Flask‑based web application that leverages GPT‑4 and OR‑Tools to solve NP‑complete problems. The application supports several problems—including the Traveling Salesman Problem (TSP), 0/1 Knapsack Problem, and Graph Coloring Problem—by classifying natural language descriptions provided by the user and then iteratively refining GPT‑4’s solution using feedback from OR‑Tools until convergence.
Features
Natural Language Problem Classification:
Enter a plain language description of your NP‑complete problem. GPT‑4 classifies it (e.g., TSP, KNAPSACK, GRAPH_COLORING) and directs you to the appropriate form.Detailed Input Forms:
Based on the classification, you can provide structured details (cities and a distance matrix for TSP, items and capacity for Knapsack, or an adjacency matrix and number of colors for Graph Coloring).Iterative Feedback Loop:
For each problem, if GPT‑4’s solution does not match the solver’s solution, the system feeds back the solver’s output to GPT‑4 until the responses converge (or a maximum number of iterations is reached).Rich Result Display:
View both GPT‑4’s solution and the OR‑Tools/CP‑SAT solution along with iteration counts and additional details (such as selected items with weights and values for the knapsack problem).
Project Structure
The repository has the following structure:
NP-complete-solver-LLM/
├── API_key.env
├── app.py
├── knapsack_module.py
├── graph_coloring_module.py
├── environment.yml
└── templates/
├── index.html
├── tsp.html
├── result.html
├── knapsack.html
├── result_knapsack.html
├── graph_coloring.html
└── result_graph_coloring.html
- API_key.env: Contains your OpenAI API key (do not commit this file).
- app.py: Main Flask application file, containing routes for NP‑complete problem classification and specific problem detail forms.
- knapsack_module.py: Contains functions to solve the knapsack problem using GPT‑4 and OR‑Tools with an iterative feedback loop.
- graph_coloring_module.py: Contains functions to solve the graph coloring problem using GPT‑4 and OR‑Tools CP‑SAT with iterative feedback.
- environment.yml: Conda environment file for reproducing the environment.
- templates/: Contains HTML templates for the home page, input forms, and result pages for each problem.
Installation with Conda
To create and activate a Conda environment based on your existing environment:
Clone the repository:
git clone https://github.com/abbaasalif/NP-complete-solver-LLM.git cd NP-complete-solver-LLMCreate the Conda environment from the existing environment file:
If you have an existing environment and want to export it:
conda env export > environment.ymlOtherwise, use the provided
environment.ymlto create the environment:conda env create -f environment.ymlActivate the environment:
conda activate np_solver
Running the Application
Start the Flask server:
python app.pyOpen your web browser and navigate to http://127.0.0.1:5000/. On the home page, you can either enter a natural language description of your NP‑complete problem or click one of the provided links to directly go to a problem form (TSP, Knapsack, or Graph Coloring).
Sample Scenarios
1. Traveling Salesman Problem (TSP) – 20 Cities
Natural Language Description:
I have a complex traveling salesman problem involving 20 cities spread over a large region. I have a detailed distance matrix that specifies the travel cost between every pair of cities. I need to find the shortest route that visits each city exactly once and returns to the starting city.
Detailed Input for TSP Form:
Cities:
City1, City2, City3, ..., City20Distance Matrix:
0, 56, 47, 78, 90, 33, 68, 59, 72, 88, 45, 60, 91, 37, 82, 49, 77, 52, 83, 65 56, 0, 65, 49, 75, 60, 80, 45, 68, 70, 57, 63, 76, 52, 69, 85, 54, 66, 74, 61 ...(Complete with 20 rows)
2. Knapsack Problem – 10 Items
Natural Language Description:
I need to solve a knapsack problem with 10 items, where each item has a weight and a value. My goal is to maximize the total value without exceeding the knapsack's capacity of 50. The items are provided in a detailed list.
Detailed Input for Knapsack Form:
Items (format “weight:value; …”):
10:60; 20:100; 30:120; 25:90; 15:50; 5:30; 12:40; 18:70; 22:80; 8:25Capacity:
50
3. Graph Coloring Problem – 6 Vertices
Natural Language Description:
I have a scheduling problem that can be modeled as a graph coloring problem. The graph is represented by an adjacency matrix for 6 vertices, and I need to assign a color (represented as a numeric index) to each vertex such that no two adjacent vertices have the same color. I want to use exactly 3 colors.
Detailed Input for Graph Coloring Form:
Adjacency Matrix:
0, 1, 1, 0, 0, 1 1, 0, 1, 1, 0, 0 1, 1, 0, 1, 1, 0 0, 1, 1, 0, 1, 1 0, 0, 1, 1, 0, 1 1, 0, 0, 1, 1, 0Number of Colors:
3Sample Scenarios
1. Traveling Salesman Problem (TSP)
Natural Language Description
I have a challenging traveling salesman problem involving 20 cities spread over a large region. The distances between these cities vary significantly, and I have compiled a detailed distance matrix. I need to determine the shortest possible route that visits each city exactly once and returns to the starting city. Please help me solve this problem.
Structured Input
Cities (comma‑separated):
City1, City2, City3, City4, City5, City6, City7, City8, City9, City10, City11, City12, City13, City14, City15, City16, City17, City18, City19, City20Distance Matrix (one row per line, comma‑separated):
0, 56, 47, 78, 90, 33, 68, 59, 72, 88, 45, 60, 91, 37, 82, 49, 77, 52, 83, 65 56, 0, 65, 49, 75, 60, 80, 45, 68, 70, 57, 63, 76, 52, 69, 85, 54, 66, 74, 61 47, 65, 0, 68, 54, 77, 59, 82, 63, 88, 45, 71, 90, 56, 67, 73, 50, 64, 80, 59 78, 49, 68, 0, 62, 74, 59, 70, 81, 55, 68, 80, 72, 63, 58, 66, 77, 52, 69, 60 90, 75, 54, 62, 0, 68, 73, 66, 80, 72, 64, 79, 85, 60, 57, 69, 71, 63, 82, 55 33, 60, 77, 74, 68, 0, 55, 68, 73, 62, 59, 65, 70, 58, 62, 80, 53, 64, 71, 60 68, 80, 59, 59, 73, 55, 0, 66, 70, 54, 62, 74, 80, 57, 63, 68, 69, 60, 75, 55 59, 45, 82, 70, 66, 68, 66, 0, 64, 72, 53, 59, 77, 56, 68, 63, 58, 71, 67, 60 72, 68, 63, 81, 80, 73, 70, 64, 0, 65, 60, 68, 74, 59, 70, 75, 62, 66, 72, 58 88, 70, 88, 55, 72, 62, 54, 72, 65, 0, 70, 60, 66, 55, 68, 57, 73, 59, 80, 61 45, 57, 45, 68, 64, 59, 62, 53, 60, 70, 0, 64, 78, 55, 61, 66, 70, 54, 65, 59 60, 63, 71, 80, 79, 65, 74, 59, 68, 60, 64, 0, 75, 57, 66, 69, 62, 70, 63, 58 91, 76, 90, 72, 85, 70, 80, 77, 74, 66, 78, 75, 0, 62, 68, 64, 79, 60, 71, 65 37, 52, 56, 63, 60, 58, 57, 56, 59, 55, 55, 57, 62, 0, 61, 68, 54, 65, 60, 52 82, 69, 67, 58, 57, 62, 63, 68, 70, 68, 61, 66, 68, 61, 0, 59, 63, 60, 75, 58 49, 85, 73, 66, 69, 80, 68, 63, 75, 57, 66, 69, 64, 68, 59, 0, 70, 54, 65, 60 77, 54, 50, 77, 71, 53, 69, 58, 62, 73, 70, 62, 79, 54, 63, 70, 0, 66, 60, 57 52, 66, 64, 52, 63, 64, 60, 71, 66, 59, 54, 70, 60, 65, 60, 54, 66, 0, 68, 59 83, 74, 80, 69, 82, 71, 75, 67, 72, 80, 65, 63, 71, 60, 75, 65, 60, 68, 0, 62 65, 61, 59, 60, 55, 60, 55, 60, 58, 61, 59, 58, 65, 52, 58, 60, 57, 59, 62, 0
2. Knapsack Problem
Natural Language Description
I need to solve a knapsack problem where I have a list of 10 items, each with a specific weight and value. My goal is to select a subset of these items that maximizes the total value without exceeding a knapsack capacity of 50. Please help me determine the optimal selection.
Detailed Input
Items (format “weight:value; weight:value; …”):
10:60; 20:100; 30:120; 25:90; 15:50; 5:30; 12:40; 18:70; 22:80; 8:25Capacity:
50
3. Graph Coloring Problem
Natural Language Description
I have a scheduling problem that can be modeled as a graph coloring problem. Each vertex in the graph represents a class, and an edge between two vertices indicates that the classes conflict (cannot be scheduled at the same time). I need to assign colors (numeric indices) to each class so that no two adjacent vertices share the same color, using exactly 3 colors. Please help me find a valid coloring solution.
Detailed Input
Adjacency Matrix (one row per line, comma-separated):
0, 1, 0, 1, 0, 1 1, 0, 1, 1, 0, 0 0, 1, 0, 1, 1, 0 1, 1, 1, 0, 1, 1 0, 0, 1, 1, 0, 1 1, 0, 0, 1, 1, 0Number of Colors:
3
How to Use These Scenarios
For TSP:
Paste the natural language description into the home page’s description field. Once the problem is classified as TSP, use the detailed input (cities and the 20×20 distance matrix) in the TSP form to solve the problem.For Knapsack:
Use the provided natural language description on the home page to have the system classify it as a knapsack problem. Then, in the knapsack form, paste the items string and enter the capacity (50).For Graph Coloring:
Enter the natural language description to have the system classify it as a graph coloring problem. In the graph coloring form, paste the provided adjacency matrix and enter the number of colors (3). —
Deep Reinforcement Learning Project
README:
Developed a Deep Q-learning based agent for HVAC system optimization
The environment is written using simplistic models based on Heat transfer equations The agent demonstrates superior performance compared to regular thermostat based control in a simulated environment and the real environment data is collected using the CPU temperature of a system while running different benchmarks over a Raspberry Pi.
The repository presents a Deep Q-learning-based agent to optimize HVAC (Heating, Ventilation, and Air Conditioning) systems. The environment is modeled using fundamental heat transfer equations, enabling the agent to outperform traditional thermostat-based controls.
Repository Structure:
brain.pyandbrain_pyt.py: Define the neural network architectures and related functions for the agent.dqn.pyanddqn_pyt.py: Implement the Deep Q-Network algorithms.environment.pyandreal_env.py: Simulate the HVAC environment using heat transfer models.training.pyandtraining_real.py: Scripts to train the agent in simulated and real environments, respectively.testing.pyandtesting_real.py: Evaluate the performance of the trained agent.train_hyper.py,train_hyper_real.py, andtrain_hyper.ipynb: Hyperparameter tuning scripts and notebook.regression_model.ipynb: Notebook detailing the development of a regression model related to the project.- Model and Scaler Files:
model.h5andmodel_real.h5: Saved models for simulated and real environments.finalized_model.savandfinalized_scaler.sav: Serialized model and scaler objects.
- Log Files:
log_sensor.csv: Contains sensor data logs.
- Hyperparameter Files:
best_hyperparameters.txtandbest_hyperparameters_real.txt: Document optimal hyperparameters for respective environments.
Getting Started:
- Clone the Repository:
git clone https://github.com/abbaasalif/drl_project.git cd drl_project - Install Dependencies: Ensure you have Python installed. Then, install the required packages:
pip install -r requirements.txtNote: If
requirements.txtis absent, manually install necessary packages such as TensorFlow, Keras, NumPy, and Pandas. - Train the Agent: To train the agent in the simulated environment:
python training.pyFor training in a real-world environment:
python training_real.py - Test the Agent: After training, evaluate the agent’s performance:
python testing.pyFor real-world environment testing:
python testing_real.py
Hyperparameter Tuning:
Utilize the provided scripts and notebook for hyperparameter optimization:
- Scripts:
train_hyper.pyandtrain_hyper_real.py - Notebook:
train_hyper.ipynb
Additional Resources:
- Regression Model Development: Refer to
regression_model.ipynbfor insights into the regression model associated with this project. - Sensor Data Logs: Examine
log_sensor.csvfor recorded sensor data during experiments.
Contributing:
Contributions are welcome. Please fork the repository and submit a pull request with detailed information about your changes.
Video 2 Event Simulator
README:
Video 2 Event Simulator
To run the video to event simulator you need to first run the python script viz_video_to_event_simulator.py
python viz_video_to_event_simulator.py -i input_video.mp4 -o output_file.dat --no_display
using the no display flag makes things faster so that the PC is not overloaded with the CV imshow as well.
further you also need to use a dat file to avi converter
For this you need to build the C++ project under the folder metavision_file_to_video
cd metavision_file_to_video
mkdir build
cd build
cmake ..
cmake --build .
Then you will have the .exe file in the build folder under the Debug folder Copy it over to the root folder
Then you can use it
./metavision_file_to_video.exe -i output.dat -o output.avi
This will create the event frame video from the original RGB video
freematch-improved
README:
FreeMatch-Improved
This repository has the implementation of FreeMatch and some of the modifications that I tried to implement. The following commits will discuss the changes and are works in progress. If you would like to use the original losses described in the paper, you need to go to the utils folder and change the init.py file to get the appropriate losses imported. This is not optimal but will be revised in the future versions.
This work is entirely inspired by the official implementation of the paper and also from https://github.com/shreejalt/freematch-pytorch
🚀 Features
- Enhanced FreeMatch Algorithm: Improved upon the original FreeMatch approach.
- Semi-Supervised Learning: Balances labeled and unlabeled data effectively.
- Customizable: Easily adjust hyperparameters for experimentation.
📖 Table of Contents
🛠️ Installation
- Clone the repository:
git clone https://github.com/abbaasalif/freematch-improved.git cd freematch-improved - Install Anaconda or Miniconda for your platform (Linux/Windows/Mac). This repository is platform-agnostic.
- Create the conda environment using the provided
environment.yml:conda env create -f environment.ymlWhy use Anaconda? It provides pre-built CUDA runtime libraries, so all you need are the appropriate drivers for your GPU to get started. ```
🎯 Usage
Configuration
These config files are identical to the https://github.com/shreejalt/freematch-pytorch repository. All the config files for CIFAR10 and CIFAR100 are present in the config folder. It follows the yacs and logging format inspired from Dassl.pytorch. You can visit the given link to learn more about yacs.config.CfgNode structure.
The script main.py contains argument parser which can be used to overwrite the config file of the experiment.
main.py [-h] [--config-file CONFIG_FILE] [--run-name RUN_NAME]
[--output-dir OUTPUT_DIR] [--log-dir LOG_DIR] [--tb-dir TB_DIR]
[--resume-checkpoint RESUME_CHECKPOINT] [--cont-train]
[--validate-only] [--train-batch-size TRAIN_BATCH_SIZE]
[--test-batch-size TEST_BATCH_SIZE] [--seed SEED]
optional arguments:
-h, --help show this help message and exit
--config-file CONFIG_FILE
Path to the config file of the experiment
--run-name RUN_NAME Run name of the experiment
--output-dir OUTPUT_DIR
Directory to save model checkpoints
--log-dir LOG_DIR Directory to save the logs
--tb-dir TB_DIR Directory to save tensorboard logs
--resume-checkpoint RESUME_CHECKPOINT
Resume path of the checkpoint
--cont-train Flag to continue training
--validate-only Flag for validation only
--train-batch-size TRAIN_BATCH_SIZE
Training batch size
--test-batch-size TEST_BATCH_SIZE
Testing batch size
--seed SEED Seed
Running the Model
- Train the model using labeled and unlabeled datasets:
python3 main.py --config-file config/cifar10/freematch_cifar10_10.yaml - Evaluate the model:
python3 main.py --validate-only --config-file config/cifar10/freematch_cifar10_10.yaml --resume logs/freematch_cifar10_10/model_ckpt/best_checkpoint.pth.
Configurations
Customize the configs/config.yaml file to:
- Change datasets.
- Adjust hyperparameters (e.g., learning rate, batch size).
🖼️ Examples
Training Example
python train.py --config configs/cifar10.yaml
Visualizing Results
The training process logs metrics like accuracy and loss. Visualize them with TensorBoard:
tensorboard --logdir=logs/
🤝 Contributing
We welcome contributions! Here’s how you can help:
- Fork the repository.
- Create a new branch:
git checkout -b feature-name - Commit your changes:
git commit -m "Add feature" - Push to the branch:
git push origin feature-name - Open a Pull Request.
📜 Citations
If you find this repository helpful, please consider citing the following works:
FreeMatch
@article{wang2023freematch,
title={FreeMatch: Self-adaptive Thresholding for Semi-supervised Learning},
author={Wang, Yidong and Chen, Hao and Heng, Qiang and Hou, Wenxin and Fan, Yue and Wu, Zhen and Wang, Jindong and Savvides, Marios and Shinozaki, Takahiro and Raj, Bhiksha and Schiele, Bernt and Xie, Xing},
booktitle={International Conference on Learning Representations (ICLR)},
year={2023}
}
USB: Unified Semi-supervised Learning Benchmark
@inproceedings{usb2022,
doi = {10.48550/ARXIV.2208.07204},
url = {https://arxiv.org/abs/2208.07204},
author = {Wang, Yidong and Chen, Hao and Fan, Yue and Sun, Wang and Tao, Ran and Hou, Wenxin and Wang, Renjie and Yang, Linyi and Zhou, Zhi and Guo, Lan-Zhe and Qi, Heli and Wu, Zhen and Li, Yu-Feng and Nakamura, Satoshi and Ye, Wei and Savvides, Marios and Raj, Bhiksha and Shinozaki, Takahiro and Schiele, Bernt and Wang, Jindong and Xie, Xing and Zhang, Yue},
title = {USB: A Unified Semi-supervised Learning Benchmark for Classification},
booktitle = {Thirty-sixth Conference on Neural Information Processing Systems Datasets and Benchmarks Track}
year = {2022}
}
Domain Generalization
@article{zhou2022domain,
title={Domain generalization: A survey},
author={Zhou, Kaiyang and Liu, Ziwei and Qiao, Yu and Xiang, Tao and Loy, Chen Change},
journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},
year={2022},
publisher={IEEE}
}
Domain Adaptive Ensemble Learning
@article{zhou2021domain,
title={Domain adaptive ensemble learning},
author={Zhou, Kaiyang and Yang, Yongxin and Qiao, Yu and Xiang, Tao},
journal={IEEE Transactions on Image Processing},
volume={30},
pages={8008--8018},
year={2021},
publisher={IEEE}
}
🛠️ Future Work
- Integrating advanced loss functions.
- Adding support for larger datasets like ImageNet.
- Enhancing model interpretability.
🙌 Acknowledgements
- FreeMatch Paper
- Contributors and the open-source community.
radon_data_analysis_darts
README:
Radon Analysis DARTS
Overview
Radon Analysis DARTS is a Python-based project focused on modeling underground soil radon gas emanation. This project leverages machine learning techniques and affinity clustering to analyze radon concentration levels efficiently and effectively.
Features
- Implementation of machine learning models:
run-all-nbeatsandrun-all-dlinear. - Models used for comparison include those under the naming scheme
45_13. - Integration of affinity clustering models for advanced analysis.
- Comprehensive preprocessing, training, and evaluation pipeline.
- Visualization tools for results and model insights.
Installation
- Clone the Repository:
git clone https://github.com/abbaasalif/radon_analysis_darts.git cd radon_analysis_darts - Set Up a Virtual Environment (Optional):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate - Install Dependencies:
pip install -r requirements.txt - Set Up the Dataset:
- Place the dataset in the
data/directory (create this directory if it does not exist). - Ensure the dataset is properly formatted as specified in the
data/README.mdfile (if available).
- Place the dataset in the
Usage
- Run Preprocessing:
python preprocess_data.py - Train N-BEATS Model:
python run-all-nbeats.py - Train D-Linear Model:
python run-all-dlinear.py - Train and Compare Models:
- Models named
45_13are used for comparison. To run these models:python run_45_13_model.py
- Models named
- Run Affinity Clustering:
- To train and evaluate affinity clustering models:
python affinity_clustering.py
- To train and evaluate affinity clustering models:
- Evaluate Results:
python evaluate.py --model checkpoints/best_model.pth - Visualize Results:
python visualize.py
File Structure
radon_analysis_darts/
├── data/ # Directory for datasets
├── configs/ # Configuration files
├── models/ # Model architectures
├── preprocess_data.py # Data preprocessing script
├── run-all-nbeats.py # N-BEATS model training
├── run-all-dlinear.py # D-Linear model training
├── run_45_13_model.py # Models for comparison
├── affinity_clustering.py # Affinity clustering model script
├── evaluate.py # Evaluation script
├── visualize.py # Visualization script
├── requirements.txt # Python dependencies
└── README.md # Project documentation
Configuration
- Configuration parameters for training, evaluation, and clustering are available in the YAML files in the
configs/directory.
Requirements
- Python 3.8 or higher
- See
requirements.txtfor a full list of dependencies.
Contributions
Contributions are welcome! To contribute:
- Fork the repository.
- Create a branch for your feature or bug fix.
- Submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
This project builds upon techniques discussed in the accompanying paper “Towards Modeling Underground Soil Radon Gas Emanation.”
hAIrmony
README:
hAIrmony
Overview
hAIrmony is a sophisticated AI-driven project designed to revolutionize personal hair care recommendations. Leveraging advanced machine learning algorithms and personalized data, hAIrmony offers tailored solutions for hair care, aiming to enhance user satisfaction and confidence. It uses a hair segmentation model with a Dall-E 2 inpainting model with prompt engineering to recommend hairstyles based on users’ pictures. to run the following code:
python roboflow_hair_seg.py
Deep Reinforcement Learning with Atari Environment
README:
Deep Reinforcement Learning with Atari Environments
Please update this file accordingly, e.g., the train and test scripts, and remove the one you don’t implement.
TA will run your test script for evluation. If you use TensorFlow, please add pip install command here.
Please use a CUDA GPU machine as the model is trained in GPU there would be issues loading it in CPU version of pytorch.
For the testing script please dont use .ckpt in the script it is added automatically -run as shown in the usage below.
For DQN
python main.py --train_dqn --model_name dqn1.ckpt -ep 20000 -b 32 -lr 0.00015
python main.py --test_dqn --model_name dqn1
This plays the Atari game and the current model is hyperparameter optimized using Optuna and surpasses most human players. The weights are not included due to size issues.