This is the first obligatory assignment of DM841 to be carried out in groups of two members. In case the number of members is different from two discuss the situation with the teacher.
The deadline is Monday, October 4, at 18. You have to submit a short report in PDF and the MiniZinc scripts implementing the model described.
The problems of the assignment for this edition of the course are taken from the LP/CP Programming Contest that runs jointly to the ICLP conference.
In 2020, 5 problems were posed:
Your task is to address and solve in MiniZinc two of those problems at your own choice. You could start trying with problems 1 and 5 and if they turn difficult find others that are more amenable.
You will need to put the input files in the form that is most convinient for your MiniZinc scripts. For this you are advised to use Python.
More specifically, for every problem you decide to solve you should carry out the following subtasks:
Report the results in tables containing at least the following columns:
If you are looking for more, you can register to this year edition of the contest.
The submission will be via IMADA Git Server at https://git.imada.sdu.dk. How to proceed in detail will be described below.
We strongly recommend using a Unix-based operating system (Mac or Linux) for the assignments.
Git is a program that manages updates between an online code repository and the copies of the repository, called clones, stored locally on computers. Git is installed in the IMADA Computer Lab. The instructions given below in this document should be enough for the needs in this course. The tutorials linked below will provide much more information than needed in this course. Nevertheless, git is an industry-standard collaboration tool, and being able to use it efficiently is an asset.
If you decide to use your own computer, and git is not already installed on your computer, you can download it at http://git-scm.com/downloads (or use the installation procedure of your specific system). If you have never used git, you might want to read a few of the following resources.
Official git tutorial: https://git-scm.com/docs/gittutorial
Bitbucket git tutorials: https://www.atlassian.com/git/tutorials
GitHub git cheat sheet: https://education.github.com/git-cheat-sheet-education.pdf
GitLab git tutorial: https://docs.gitlab.com/ce/gitlab-basics/start-using-git.html
Codecademy git lesson: https://www.codecademy.com/learn/learn-git
Training video series by GitHub: YouTube PlayList
There are many websites for hosting online git repositories. IMADA has its own server for hosting git repositories https://git.imada.sdu.dk. While not needed for submitting your code, you can login to the webpage using your university account name and the same password as you use for reading your mail or logging into blackboard. Choose as authentication source “SDU”.
Clone your existing repository.
Usually, you have to create a repository. However, we already created a repository for each student of DM841. You will not have to create any repositories, but only clone it.
Connect your folder to the new repository. In a shell application (Terminal on Linux or Mac, or Git Bash (https://gitforwindows.org/ on Windows), enter the following commands (we will use the student with the username “username” as example, of course you have to change this).
Navigate to the folder where you want to store your files
$ cd /path/to/folder # cd means 'change directory'.
Make sure you are in the right place.
$ pwd # pwd means 'print working directory'.
/path/to/folder
# Clone the repository we provided
$ git clone https://git.imada.sdu.dk/DM841_21/Repo_<username>.git
Cloning into 'username-repo'...
Username for 'https://git.imada.sdu.dk': username
Password for 'https://username@git.imada.sdu.dk': ********
remote: Counting objects: 48, done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 48 (delta 16), reused 0 (delta 0)
Unpacking objects: 100% (48/48), done.
$ ls
Repo_<username>
$ cd Repo_<username>
$ ls -rtl
total 8
drwxrwxr-x 4 marco marco 4096 Oct 1 09:31 asg1
-rw-rw-r-- 1 marco marco 31 Oct 1 09:32 README.md
# Record your credentials (has to be done once only).
$ git config --local user.name "Firstname Surname"
$ git config --local user.email "username@student.sdu.dk"
Git manages the history of a file system through commits, or
checkpoints. Use to see the files that have been changed since the last
commit. These changes are then moved to the (local) staging area (a
list of files for the next commit) git add <filename>
. Record then the changes to
the staging area with git commit -m "<message>"
.
All these commands are done within a “clone” of the repository, which
is stored somewhere on a computer. This repository must be manually
synchronized with the remote repository server via two other git
commands: git pull
, to pull updates from the web to the computer; and
git push
, to push
updates from the computer to the git server.
For the assignments in DM841 you will have first to add your files to the staging area, then it has to be commited, and then it has to be pushed to the remote server.
Command | Explanation |
---|---|
git status |
Display the staging area and untracked changes. |
git pull |
Pull changes from the online repository. |
git push |
Push changes to the online repository. |
git add <files> |
Add a file or files to the staging area. |
git commit -m "<message>" |
Save the changes in the staging area with a given message. |
Some additional commands you might need in DM841:
Command | Explanation |
---|---|
git add <files> |
Add all modified, tracked files to the staging area. |
git checkout -- <filename> |
Revert changes to an unstaged file since the last commit. |
git reset HEAD -- <filename> |
Remove a file from the staging area. |
git diff <filename> |
See the changes to an unstaged file since the last commit. |
git diff --cached <filename> |
See the changes to a staged file since the last commit. |
git config --local <option> |
Record your credentials (user.name, user.email, etc.). |
Cloning and giving details on your name and email has only to be done once. The below work session assumes this has been done already.
Short version:
$ cd ~/Courses/DM841/Assignments/Repo_<username>
$ git pull # Pull updates.
# Make changes to a file (in this example src/onlytesting.py)
# Record the changes in git.
$ git add asg1/src/preprocess.py # Track changes.
$ git commit -m "Made some changes." # Commit changes.
$ git push # Push updates.
Long version:
# Navigate to the clone of the repository.
$ cd ~/Courses/DM841/Assignments/Repo_<username>
# Pull any updates from the online repository, if they exist.
$ git pull
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From https://git.imada.sdu.dk/DM841_21/Repo_<username>
6dde06d..e24cee5 master -> origin/master
Updating 6dde06d..e24cee5
Fast-forward
asg1/src/preprocess.py/ | 33 +++++----------------------------
1 file changed, 5 insertions(+), 28 deletions(-)
# Work on the assignment. For example, modify asg1/src/preprocessing.py
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: asg1/src/preprocessing.py
no changes added to commit (use "git add" and/or "git commit -a")
$ git add asg1/src/preprocessing.py
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: asg1/src/preprocessing.py
# Commit the changes to the repository with an informative message.
$ git commit -m "Made some changes"
[master 72a5ab3] Made some changes
1 file changed, 1 insertion(+)
<<[master fed9b34] Made some changes
1 file changed, 10 insertion(+) 1 deletion(-)>>
# Push the changes to the online repository.
$ git push
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 373 bytes | 373.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0)
To https://git.imada.sdu.dk/DM841_21/Repo_<username>.git
e24cee5..72a5ab3 master -> master
# The changes have been saved and the online repository updated.
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
Use the following structure and names for your repository, where prob1
and prob5
are the problems solved (yours might be different):
Repo_march$ tree
.
├── asg1
│ ├── prob1
│ │ ├── data
│ │ ├── doc
│ │ └── src
│ │ └── run.sh
│ ├── prob5
│ │ ├── data
│ │ ├── doc
│ │ └── src
│ │ └── run.sh
│ └── README.md
└── README.md
9 directories, 4 files
The file run.sh could look as follows:
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Instance name missing"
exit 1
fi
python3 prepare_data.py $1 # preparing the instance in dzn format
minizinc -s model.mzn data.dzn > output.sln
python3 postprocess.py output.sln # gatering the output and rewriting
The output of run.sh
must be the one and only that is specified in the
problem description.
Make sure run.sh
is in executable mode:
ls -rtl asg1/prob1/src/
total 4
-rwxrwxr-x 1 marco marco 201 Sep 30 20:02 run.sh