This code solves a simple optimization problem, and intended to be an learning exercise.
The code "q1.py" calculates an objective function and outputs the results with the lowest values.
In "test_q1.py", the unit test routines are provided.
These codes have a few dependencies that are required: numpy, argparse, multiprocessing, and unittest
First, make sure "pipenv" is installed in your system. On Ubuntu linux, this can be done via:
$ pip install --user pipenv
Once, pipenv is installed, one can start the virtual environment shell, and run the code by doing the followings in the project folder.
$ pipenv shell
$ ./q1.py input.txtMake sure the above mentioned dependencies are installed in your system. On Ubuntu Linux, one would do:
$ sudo apt install python-numpy
Afterwards, code is run via:
$ ./q1.py input.txt
To see the help page, do:
$ ./q1.py -h
The script requires an input file. Optionally output file name can be indicated:
$ ./q1.py --output somefile.txt input.txt
In order to run the parallel version of the calculation, use the '-p' or '--parallel' flag:
$ ./q1.py -p input.txt
Unit tests can be run via:
$ ./test_q1.py