Commit 9617d9e7 authored by Kučera Petr RNDr. Ph.D.'s avatar Kučera Petr RNDr. Ph.D.
Browse files

readme update, model file

parent 0d5a9b24
Default directory for storing graph related files.
/*********************************************
* OPL 12.8.0.0 Model
* next activity is chosen by alternative activity
* check next activity and prev activity
*********************************************/
using CP;
// ... loads data from *.dat file
{string} Trains = ...;
{string} Places = ...;
// structure for a single activity
tuple ActivityInfo {
key string activity_name;
int needed;
int start_min;
int end_max;
int duration_min;
int duration_max;
string place;
{string} prev_activity;
{string} next_activity;
int transition;
};
{ActivityInfo} activities[Trains] = ...;
// mix activities separated by train name into one set
tuple TrainActivityMatch {
ActivityInfo activity_info;
string train_name;
};
{TrainActivityMatch} all_activities = {<a,t> | t in Trains, a in activities[t]};
// for each activity, find what are possible previous and next activities
int next_act[a in all_activities][b in all_activities];
int prev_act[a in all_activities][b in all_activities];
execute
{
for (i in all_activities)
{
for (j in all_activities)
{
next_act[i][j] = 0;
prev_act[i][j] = 0;
if (i.activity_info.next_activity.contains(j.activity_info.activity_name) && i.train_name == j.train_name)
next_act[i][j] = 1;
if (i.activity_info.prev_activity.contains(j.activity_info.activity_name) && i.train_name == j.train_name)
prev_act[i][j] = 1;
}
}
}
// decision variables
dvar interval activity[a in all_activities] optional
in a.activity_info.start_min..a.activity_info.end_max
size a.activity_info.duration_min..a.activity_info.duration_max;
dvar interval alternative_next_activity[a in all_activities] optional;
dvar interval alternative_prev_activity[a in all_activities] optional;
dvar sequence used_places[p in Places] in
all(a in all_activities: a.activity_info.place==p) activity[a];
// constraints on the variables
subject to
{
// no overlap for each location
forall (p in Places)
noOverlap(used_places[p]);
// the activities that need to be present
forall (a in all_activities)
if (a.activity_info.needed==1)
presenceOf(activity[a]);
// alternative activities (choose from next_activity) - first add dummy activity
forall (a in all_activities)
{
presenceOf(activity[a]) => presenceOf(alternative_next_activity[a]);
presenceOf(activity[a]) => presenceOf(alternative_prev_activity[a]);
endAtStart(activity[a],alternative_next_activity[a],-a.activity_info.transition);
}
// the dummy activity chooses the alternative next activity - it starts at the same time
forall (a in all_activities)
if (card(a.activity_info.next_activity) >= 1)
alternative(alternative_next_activity[a], all(b in all_activities: next_act[a][b] == 1) activity[b]);
forall (a in all_activities)
if (card(a.activity_info.prev_activity) >= 1)
alternative(alternative_prev_activity[a], all(b in all_activities: prev_act[a][b] == 1) activity[b]);
}
Default directory for the output files
# Compilation
To compile the project, run
```bash
make cmake
make
```
C++17 compiler is needed to compile the project, otherwise it does not have any
prerequisities.
# Running on example data
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment