-
The objective of this project is to construct a polygonal containment field that captures the maximum value of crystals on a 2D grid while minimizing the inclusion of void mines.
-
This is an NP-Hard optimization problem, and our approach uses efficient heuristics such as:
- Kadane’s Algorithm (extended to 2D for rectangular subregions).
- Dynamic Programming strategies for optimal substructure exploitation.
- Our solution aims to provide a near-optimal answer in a reasonable time, balancing performance with accuracy.
- C++ compiler (g++ recommended)
- Make sure you have C++11 or higher
To compile the program, use the following command:
g++ -o program 57_optimization_code.cppIf you need to specify a specific C++ standard, use:
g++ -std=c++11 -o program 57_optimization_code.cppAfter compilation, run the program using:
./programYou will have to enter the number of test cases in the terminal when asked to.
The program will:
- Read data from all input files
- Process the grid data
- Generate output in separate output files
- Display the results in the console
Input files must be named as "input00.txt", "input01.txt" and so on.
Each input file should contain:
- First line: Number N (integer)
- Next N lines: Three space-separated integers (x, y, value)
- Then: Number M (integer)
- Next M lines: Three space-separated integers (x, y, value) Make sure that the input files are in the same directory as the code file
If you encounter errors:
- Check if the input file exists and is correctly formatted
- Ensure you have write permissions in the directory (for output files)
- Make sure you are using a compatible C++ version
This program uses large vectors (10000 x 10000). Therefore, we recommend you to ensure your system has sufficient memory available.