I have a problem with my code. I always get too out of memory error.
I tried simplifying the data... the outcome is no optimization at all. it simple gave me straight ones to the ho variable.
I am sure there is sthg wrong with the structure that i cannot see due to my lack of experience in this domain.
# algorithm to predict vehicles destination and compare it with the
#real life ones for validation
param T := 744;
set ID; # location ids
set Veh; #drivers
set socialSphere within {Veh,ID};
set Destinations within {Veh,ID,1..T};
set home within {Veh,ID};
set work within {Veh,ID};
set study within {Veh,ID};
set leisure within {Veh,ID};
param attHome{Veh,ID} >= 0;#the weight of the attraction between a vehicle and a locatoion of type home.
param attWork{Veh,ID} >= 0;
param attStudy{Veh,ID} >= 0;
param attLeisure{Veh,ID} >= 0;
#indicates the importance variation of each location type with time
var ho {1..T} >= 0;
var wo {1..T} >= 0;
var st {1..T} >= 0;
var le {1..T} >= 0;
#calculate the attraction of a driver to each of the locations
#in its social sphere according to the type of the location
var locAttraction{v in Veh,e in ID,t in 1..T}=
(if (v,e) in home
then ho [t]*attHome[v,e]
else if (v,e) in work
then wo [t]*attWork[v,e]
else if (v,e) in study
then st [t]*attStudy[v,e]
else if (v,e) in leisure
then le [t]*attLeisure[v,e]
else 0
);
#getting the score of the maximumlocation
var maxLoc{v in Veh,t in 1..T}=max {e in ID} locAttraction[v,e,t];
#trying to get the location having the maximum score (substitute of argmax)
# that at the same time matches the real life location
var chosenLoc{v in Veh,e in ID,t in 1..T}=
(if (v,e,t) in Destinations
then (if ( (v,e) in socialSphere and locAttraction[v,e,t] = maxLoc[v,t] and Destination[v,t]=e)
then 1 else 0));
#since more than one locaation can have the same attraction.
#it is cheking that for each vehicle there is at least one match
# with the real of a maximum soredd location with the real life location
var matching{v in Veh,t in 1..T}=
(if (
(sum{e in ID } chosenLoc[v,e,t] ) >0 )
then 1 else 0);
#maximising the number of matches, i.e vehcles whose chosen location
# match the real life ones
maximize Total_match:
sum {v in Veh, t in 1..T} matching[v,t] ;
# since the possible the algorith favours one type of attracion rather than
#the other, attractions should sum up to one to ease the comparaison.
subject to Time {t in 1..T}:
ho [t]+wo [t]+st [t]+le [t]=1;