Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Questions about TOMLAB
Replies: 1   Last Post: Aug 9, 2009 3:52 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Eclipse

Posts: 6
Registered: 7/23/09
Questions about TOMLAB
Posted: Jul 27, 2009 10:40 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I am studying timetabling by the examples given in tomsym, but I seem to have misunderstanding in the definition of tomArray.
Question1:
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.
Question2:
Is it possible to use a variable which class is of 'tomArrayIdx' to indicate the subsindex of a matrix in matlab?


My problem in detail:
I have studied your case in tomSym,which is to establish a college timetable. (http://tomsym.com/examples/tomsym_collegetimetable.html).They 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=[4 2;4 1;6 1]; %three teachers,first column 4 4 6 are their desirable schedule perweek, second column is the kind of classrooms they wanted to teach in(1 is for multimedia classroom,2 is for auditorium)
course=[2 50 2;2 30 1;3 40 1;2 25 2;2 60 1]; %5 courses and their properties,first column:lessons per week,second column:number of students attending the class,third column is the kind of classroom the courses to be taught in(1 is for multimedia classroom,2 is for auditorium)
slots=4*5; %numbers of slots:4 classes per day, 5 workdays a week
room=[100 2;100 1;100 1;50 2;50 1;50 1;50 1;... %18 rooms and their properties,first column:maximum number of seats in the classroom.second column:the property of the classrooms(1 is for multimedia classroom,2 is for auditorium)
60 1;60 1;60 2;60 1;60 3;40 3;...
40 3;40 3;40 2;50 1;40 1];
t=tomArrayIdx('t',1:size(teacher,1));
l=tomArrayIdx('l',1:size(course,1));
s=tomArrayIdx('s',1:slots);
r=tomArrayIdx('r',1:size(room,1));
teach=tom('teach',3*5*20*18,1,'int');
teach=tomArray(teach,[3,5,20,18]);
bnds1={0<=teach<=1}; %variables are binary
bnds2={sum(sum(sum(teach(t,l,s,r),s),t),r)==course(:,1)}; %all courses must be taught
bnds3={sum(sum(teach(t,l,s,r),t),l)<=1}; %only one lesson in the classroom at one time
bnds4={sum(sum(teach(t,l,s,r),r),l)<=1}; %one teacher can only teach one lesson at a time
bnds5={room(r,1)>=course(r,3)}; %###REPORTS ERROR###seats in the classroom must be greater than the number of students attending the course
bnds={bnds1,bnds2,bnds3,bnds4,bnds5};
not_so_good_slots=tomArrayIdx('s',[1,4,5,8,9,12,13,16,17,20]); %this is the same with your example in tomsym:establishing a college timetable
objective1=sum(vec(teach(t,l,not_so_good_slots,r)));
objective2=0;
for i=1:3
overwork=sum(sum(sum(teach(t,l,s,r),s),l),r)-teacher(i,1); %###REPORTS ERROR###minimize the overtime of the teachers
if overwork>0
objective2=objective2+10*abs(overwork);
end
end
objective={objective1,objective2};
options=struct;
options.solver='cplex';
options.name='Timetable';
sol=ezsolve(objective,bnds,[],options);

When i enter
for i=1:3
overwork=sum(sum(sum(teach(t,l,s,r),s),l),r)-teacher(i,1);
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{:});

When i entered:
bnds5={room(r,1)>=course(r,3)};
it says
??? Error using ==> subsindex
Function 'subsindex' is not defined for values of class 'tomArrayIdx'.

Could you give me some suggestions on how to implement these on tomlab?
Thanks for your attention.Any suggestions are appreciated.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.