Eclipse
Posts:
6
Registered:
7/23/09


Can we compare values in tomArray?
Posted:
Jul 26, 2009 9:03 PM


Hello Everyone, I seem to have misunderstanding in the definition of tomArray.If a 1*1 tomarray 'overwork' : which is:overwork = tomArray() with tomSym data: sum(vec(sum(teach([... 20 by 5 array ...]),1)),1)4 How can I write my program to compare each value of overwork with the value zero, I tried to use 'overwork>0' or 'overwork(i)>0' but it can't work. How can I chage it into a matrix or something like that. My problem in detail: I have studied your case in tomSym,which is to establish a college timetable. You use tomArrayIdx to create a tomarray of multidimensions. I tried to apply it into a similiar case I have encountered. 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 I tried to minimize 'overwork' time.
My program using tomlab: teacher=[1 2 3]; lesson=[1 2 3 4 5]; lesson_times=[4 4 6 4 3]; slots=4*5; for i=1:length(lesson) if lesson_times(i)==3 lesson_times(i)=4; end lesson_times(i)=lesson_times(i)/2; end t=tomArrayIdx('t',1:3); l=tomArrayIdx('l',1:length(lesson)); s=tomArrayIdx('s',1:20); teach=tom('teach',3*5*20,1,'int'); teach=tomArray(teach,[3,5,20]); bnds1={0<=teach<=1}; bnds2={sum(sum(teach(t,l,s),s),t)==lesson_times}; bnds3={sum(sum(teach(t,l,s),t),l)<=1}; bnds={bnds1,bnds2,bnds3}; badslots=tomArrayIdx('s',[1,4,5,8,9,12,13,16,17,20]); objective1=sum(vec(teach(t,l,badslots))); max_work=[4 4 6]; 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 it says: ??? Function 'gt' is not defined for values of class 'tomArray'.
Error in ==> gt at 18 [varargout{1:nargout}] = builtin('gt', varargin{:}); Thanks a lot. Sincerely,

