Eclipse
Posts:
6
Registered:
7/23/09
|
|
In need of some help of the usage of tomlab
Posted:
Jul 25, 2009 4:59 AM
|
|
Hello all, I'm currently trying to establishing a timetable and i'm doing it with tomlab, as they have a similiar case see: tomsym.com/examples/tomsym_collegetimetable.html
As i'm a green hand to matlab. I first tried to simplify my program and try to do a program similiar to the example given.
The timetable in my program: there are 3 teachers, 5 courses(each lesson has 2,2,3,2,2 lessons per week respectively),these teachers can teach any of these 5 courses.there are 5 workdays a week and each day has 4 slots. Objective1:The desirable time for students to have courses are the 2nd and 3rd slots each day. so we have to minimize the courses' appearing on the 1st and 4th slots each day. Objective2:The desirable schedule in the part of the 3 teachers are to teach only 2,2,3 courses per week respectively.This can't be satisfied,due to the prescribed courses per week is 2+2+3+2+2,and it's larger than 2+2+3.but we can minimize 'overwork' time.
My program using tomlab: teacher=[1 2 3]; lesson=[1 2 3 4 5]; lesson_times=[2 2 3 2 2]; slots=4*5; t=tomArrayIdx('t',1:3); l=tomArrayIdx('l',1:length(lesson)); s=tomArrayIdx('s',1:20); teach=tomArray('teach',[3,5,20]); %create a array of 3*5*20 (teacher*lesson*slots)
bnds1={0<=teach<=1}; % All variables are binary
bnds2={sum(sum(teach(t,l,s),s),t)==lesson_times}; %the prescribed lessons must be satisfied
bnds3={sum(sum(teach(t,l,s),t),l)<=1}; % Teacher constraint, one teacher per slot
bnds={bnds1,bnds2,bnds3};
not_so_good_slots=tomArrayIdx('l',[1,4,5,8,9,12,13,16,17,20]); objective1=sum(vec(teach(l,t,not_so_good_slots))); %the goal is to minimize teaching courses in these no so good slots
max_work=[2 2 3]; objective2=0; for i=1:3 overwork=sum(sum(teach(i,l,s),s),l)-max_work(i) if overwork>0 objective2=objective2+10*abs(overwork); end end
However, when i typed in
objective1=sum(vec(teach(l,t,not_so_good_slots)));
it says:Error in ==> tomArray.subsref at 78 checkIndexes(o);
And when i typed in
for i=1:3 overwork=sum(sum(teach(i,l,s),s),l)-max_work(i) if overwork>0 objective2=objective2+10*abs(overwork); end end
it says:??? Function 'gt' is not defined for values of class 'tomArray'.
Error in ==> gt at 18 [varargout{1:nargout}] = builtin('gt', varargin{:});
I have checked my program several times and could not find out what is wrong, can anybody give me suggestions , or some relative material to help me understand? Thanks a lot!
|
|