Sunday, June 29, 2008
i-TimeTabler 010: Added Hours Per Week Constraint Checking
The program can now check if the Hours Assigned has
exceeded the Hours Per Week. If yes, it will not allocate the
subject, but will show a message box to inform the user
instead.
To Do:
1. If user clicks the Clear All button, or closes the program
without Clicking the Update button, the program should
undo all the increments or decrements made to the
Hours Assigned field of the Subject Table.
Friday, June 27, 2008
i-TimeTabler 009: Added Subject Details TextBox
Done:
Added Subject Details Textbox. Now, when user selects the
Subject Code from the Combo Box, the details of that
subject, eg, Hours Per Week and Hours Assigned will
be displayed.
To Do:
1. To add code logic such that whenever a subject is assigned
a slot, the attribute HoursAssigned will automatically be incremented
by 1.
2. To find a way to add another field to Subject Table
called "May not clash with". This field will contain the
Subject code of another subject that this subject should not
share the same time with.
3. To add more details to the Subject Details Textbox.
i-TimeTabler 008: Added Options for Insert Mode or Delete Mode
i-TimeTabler 007: Binded Customized Table to Database
1. Binded customized Table to inti.mdb database.
2. Added Clear All Button.
3. Implemented single-click method to enter subject code
To Do:
1. To find a way to clear single cell.
2. To find a way to show details of any subject selected
via using the subject combo box. This is so that, the user
wll know information such as how many hours left, which
room has been assigned and at what times. This will
assist the user to make proper decisions when allocating
time slots using the Customized Table at the bottom
of the Room Maintenance Form
Thursday, June 26, 2008
i-TimeTabler Notes: Invalid Use of Null Error
If IsNull(myRecordset.Fields("FieldName").Value) Then
Text1.Text = ""
Else
Text1.Text = myRecordset.Fields("FieldName").Value
End If
Or
Text1.Text = myRecordset.Fields("FieldName").Value & ""
From:
Si the Geek in vbforums
i-TimeTabler 006: Binding Customised Table to Database
Writing code to bind the Customised Table in Room
Maintenance Form to the inti.mdb database
i-TimeTabler 005: Added Customized Table
Wednesday, June 25, 2008
i-TimeTabler 004: Adding Customised DataGrid
i-TimeTabler 003: Added Record Editing for Teacher Form
Done:
1. Added Record Editing Capability for Teacher Maintenance Form.
To edit a record, click on the desired Row in the Table and
it will populate the TextBoxes. Edit the data and click on the button
called Update.
To Do:
1. Add similar record editing capability for Subject Maintenance Form
and Room Maintenance Form
Tuesday, June 24, 2008
i-TimeTabler 001: Teacher and Subject Forms Added
called i-TimeTabler 001:
Done:
1. Created an inti.mdb database containing 2 tables, viz.
TeacherTable and SubjectTable
2. Added Teacher Maintenance Form and Subject Maintenance
Form and linked them to the inti.mdb database using Data
Environment Designer.
3. All Forms are MDI Children which runs inside an MDI Parent
container Form.
To Do:
1. Insert a ComboBox in Teacher Maintenance form that
is populated by the Subject Code field of the SubjetTable.
2. Add Room Maintenance Form
3. Link Recordsets to Excel Tables
Monday, June 23, 2008
i-TimeTabler Notes: Creating Excel file, and loading into VB6 Form
populate it with data with modified cells, and then load
the Excel worksheet into the VB6 Form as an OLE object.
Source Code:
Text version:
'---- Early Binding--------
'Dim xlApp As Excel.Application
'Dim xlBook As Excel.Workbook
'Dim xlSheet As Excel.Worksheet
'----- Late Binding --------
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object
Private Sub Form_Load()
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlApp.DisplayAlerts = False
End Sub
Private Sub cmdCreateExcel_Click()
'xlApp.Application.Visible = True
xlSheet.Cells(1, 3).Value = "CSC200" & Chr(10) & "LR511"
With xlSheet
.Range(xlSheet.Cells(1, 3), xlSheet.Cells(1, 4)).MergeCells = True
'.Range("C1:D1").MergeCells = True
.Range("C1:D1").Font.Bold = True
.Range("C1:D1").Font.ColorIndex = 51
.Range("C1:D1").ColumnWidth = 6
.Range("C1:D1").RowHeight = 35
.Range("C1:D1").HorizontalAlignment = xlDistributed
.Range("C1:D1").VerticalAlignment = xlDistributed
End With
xlBook.SaveAs App.Path & "\MyFile.xls"
OLE1.CreateLink SourceDoc:=App.Path & "\MyFile.xls"
OLE1.Refresh
Call CleanUp
End Sub
Private Sub CleanUp()
'xlApp.Application.Visible = False
Set xlSheet = Nothing
'xlBook.Close SaveChanges:=False
Set xlBook = Nothing
xlApp.Application.Quit
Set xlApp = Nothing
End Sub
i-TimeTabler Notes: Suppressing Alerts
'Load Excel and create the object
Set oXL = CreateObject("Excel.Application")
'Turn off alert messages.
oXL.DisplayAlerts = False
i-TimeTable Notes: Excel Late Binding
as Objects and the Reference to the Excel library must be
removed. And you must add a module that contains
all Constants used (eg, xlCenter) . This module can
be download from microsoft ( support.microsoft.com)
Insert the module: XL97CONS.bas
Below is the code for late-binding:
Sunday, June 22, 2008
i-TimeTabler Notes: Merging Excel Cells and Setting Cell Size
You can set cell size:
Private Sub cmdMergeCells_Click()
xlApp.Application.Visible = True
xlSheet.Cells(1, 3).Value = "AB CD"
With xlSheet
.Range(xlSheet.Cells(1, 3), xlSheet.Cells(1, 4)).MergeCells = True
'.Range("C1:D1").MergeCells = True
.Range("C1:D1").Font.Bold = True
.Range("C1:D1").Font.ColorIndex = 50
.Range("C1:D1").ColumnWidth = 6
.Range("C1:D1").RowHeight = 35
.Range("C1:D1").HorizontalAlignment = xlDistributed
.Range("C1:D1").VerticalAlignment = xlDistributed
End With
End Sub
Thursday, June 19, 2008
Project: i-TimeTabler (Inti Time Tabler System)
i-TimeTabler (Inti Time Tabler System).
It is coded in VB6 and Access. Note that IntiCas was coded in
Java.
Inti Time Tabler blog posts will be in the form:
i-TimeTabler XXX
And below are some useful links.
Data Access Dreams with VB's Data Environment! (Part 1)
Accessing Databases using Data Environment Control by Saul Greenburg
Can work with Access2003
ADO Data Environment Designer by johnsmiley
Accessing Databases using ADO by Saul Greenburg
Can work with Access2003
Acessing Databases using Data Control by Saul Greenburg
Disadvantage is that you will need to convert the Access
Database to Access97 format.
Other VB Tutorials by Saul Greenburg
VB Tutorials on TutorialFind
Creating Reports using Data Report Designer by S.S. Ahmed
Wallpapers:
Vista Wallpapers
VB6 Wheelmouse Fix:
Wheel mouse do not work in VB6 - fix by microsoft
VB6 and Excel:
How to Automate Excel from VB6 (vbforums)
Must read. Extremely useful. Also explains how to
populate Excel sheet from Recordsets.
Intro to OLE in VB by Skip Munk
Wednesday, June 18, 2008
IntiCas 035: PJTable - Added Time and Day
Changing Fonts and Colors
TextArea text = new TextArea();
Font font = new Font("Serif", Font.ITALIC, 20);
text.setFont(font);
text.setForeground(Color.blue);
f.add(text, BorderLayout.CENTER);
Intica 034: PJTable
Tuesday, June 17, 2008
JExcel Api (Open Source) Programming
and the other is a Commercial one. They are not the same and
they are by different people. Below are listed the resources
for the Open Source one.
JExcelApi Open Source
How to add JExcel Api to NetBeans IDE
JExcelApi Yahoo Group
AndyKhan's Tutorial
Output an Excel file from a Servlet
http://www.jfree.org/jfreechart/
Sunday, June 15, 2008
Saturday, June 14, 2008
Useful Libraries and Cell Merging
http://forum.java.sun.com/thread.jspa?threadID=518223&messageID=2474422
http://objectmix.com/java/200334-jtable-merging-cells.html
Charting Libraries:
http://www.jfree.org/jfreechart/
Reporting Libraries
http://www.jfree.org/jfreereport/index.php
Spreadsheet Libraries
http://www.jfree.org/jworkbook/
JExcelApi (Open Source)i
JExcelApi Yahoo Group (Open Source)
How to Add JExcel Library to NetBeans(Open Soource)
JExcel Api (Not the same as above - this one is commercial)
JExcel-PGuide (commercial one)
QuickTable
QuickTable Forum
JDataGrid Spreadsheet Edition
Friday, June 13, 2008
IntiCas 033: Fixed Multi-Slot Overlap Bug
Fixed the Multi-Slot Overlap Bug.
This means that no subject is ever allocated more than once
per day. This is true also for subjects that span multiple
rooms.
However, note that another bug is created -
the Room Not Full Bug. That is, the allocation went
on to a new room even when the second room is not
yet full.
To Do:
Fix the Room Not Full Bug
Thursday, June 12, 2008
Genetic Algorithms
Andy from forum.java.sun.com :
I wrote systems to do this for my dissertation last year to
determine the best optimisation methods that should be
used to do this given a set of constraints. In my opinion the
best way you should go about doing this by using a genetic
algorithm. It finds the best timetable solutions quicker than
any other and is less prone to get stuck on local mini/maxima
than other methods, such as simulated annealing and so is
more likely to reach the optimal value
So look at some GAs. You can easily assign penalties for the
solutions you system comes up with by altering the fitness
function of the given solution. You will need to look at how
you are going to encode the chromosome too - this is essential!
Wednesday, June 11, 2008
Inticas 032: Fixed Room-Not-Full Bug
Fixed the Room-Not-Full Bug.
All Rooms are fully slotted before going to next room.
However, the algorithm created a new bug - notice the circled
red above where CSC100 is allocated twice in a day - but
in different rooms. LR100 Wednesday is a 2-hour slot
(8 am -10 am) whiltst LR200 is a single slot (12 noon - 1pm).
This violates the constraint that a subject should not have
more than 2 slots in a single day. Another serious bug
is the possiblility that the 2-hour slot may be slotted at the
same times as its corresponding 1-hour slot but in different
rooms. Note the Purple circled slots for CSC250.
I call this the "Multi-slot Overlap Bug".
To Do:
Fix the Multi-Slot Overlap Bug.
One possible way to solve it might be to modify the
Subject Class
to include attributes that store Days data, using a simple
array:
private int day[] = new int[7];
If a subject has already been allocated to
a Wednesday at 2pm, we do this:
day[3] = 14;
public boolean isDayDone(int day){
//Day checking code here
}
Before a Room Object allocates, it could perform a check
as follows:
if(!room[3].isDayDone(3)){
//Allocation code here
}
Till then...
IntiCas 031: Fixed One-Per-Day DoubleAllocation Bug
Fixed the One-Per-Day DoubleAllocation Bug.
The bug was that the program allocated the same 2-hour
slot more than once per day.
It is now fixed.
However, I notice another bug. In the screen shot above,
notice that, although LR100 was not full, the program
went ahead to LR200 ("Room-Not-Full Bug").
To Do:
Fix the Room-Not-Full Bug above.
IntiCas 030: Horizontal Double/Single Allocations OK
Successfully done Horizontal Single Allocation.
Successfully done Horizontal Double + Single Allocation.
I then went on to do One Double Allocation Per Day and
got stuck here.
To Do:
To debug the OnePerDayDouble Allocation algorithm.
Tuesday, June 10, 2008
IntiCas 029: Horizontal Single-Slot Algorithm OK
IntiCas Algorithm 004: Slot by slot Iterative Approach
seriously re-thinking the algorithm design.
The Vertical Allocation Algorithm seems unsuitable. It can only do
simple allocation.
I'm considering going back to Horizontal algorithms - ie. where the
slots are assigned horizontally Mon: 8am to 7pm, Tues: 8am to 7pm etc.
In the Vertical Algorithms, it was 8am: Mon to Sat, 9am: Mon to Sat etc.
In this new approach, I'm going to do:
1. For each and every slot, iterate through each Subject
2. Do Triple allocation first. Go through each Subject.
3. If the Subject has Triple slot attributes, enter that
Subject into the slot. Then, move to another Subject and
repeat the procedure. If there is insufficient triple slot,
move onto another day. If at any time, the triple slots
become exhausted (i.e. when we are at the Sat 5pm slot and
there is only 2 hours left), then, move onto another room
4. Then Do Double allocation next. Repeat the procedure in
Step 3 above again, but allocate 2 slots instead of 3.
5. Finally do Single allocation and repeat Step 3.
Each Subject will need to have 3 attributes:
boolean hasTripleAllocation;
boolean hasDoubleAllocation;
boolean hasSingleAllocation;
The AddSubject Frame and its JTable will also need to be
redesigned to enable User to enter these additional
attributes.
However, I will do all the above changes in stages.
First stage, I will just write the new algorithm to assign
Double Slots, followed by Single Slots.
If this works, I will then consider the other changes.
Till then...
Objectives, Constraints and Requirements of IntiCas
Objective:
To create a system which can auto-generate time tables based on user-defined
constraints on:
Classroom
Subject
Lecturer
Students
Miss Liew (Classroom Time-Tables Planner):
1. Cross lecturing – Different program, different course code
but the same lecturer (similar subject)
2. Same timeslot – Same timeslot for the same program &
3. Semester with more than one lecture. Eg, DIT/2, CSC 119
and CSC 114 can run simultaneously as different students
4. Different Lecturer – Same program & semester same course
code but by two lecturers. Lecture one lecturer and Lab by
another lecturer.
5. Classrooms – Same slot for classroom for two lectures.
This is due to we have different programs which have different
teaching calendar.
Other Constraints:
1. Must be able to specify on a subject-by-subject basis the min
hours per slot and the max hours per slot, eg, some Subjects
can take 1 to 3 hours per slots.
2. Certain Subjects may split into two Groups, Group A and Group B,
both being taught by the same Teacher.
3. Some Subjects may have 2 Teachers. One Teacher for lectures,
and a different Teacher for Labs.
4. There are not more than 50 rooms (including Labs).
Monday, June 9, 2008
IntiCas 028: Trying Set Double Slots Algorithm
So I now begin experimenting with Set Double Slots Algorithm:
What this means is that, each subject will be allocated
fixed 2-hour slots.
For this test:
if(subject[s].getRemainderHours()<=6)
I tried several values ranging from 1 to 6.
But it is not working properly.
Some subjects exceed maximum hours, while some
fall short.
To Do:
Fix the Set Double Slots Algorithm bugs.
IntiCas 027: Fixed Gap Bug in Vertical Allocation Algorithm
Fixed the Gap Bug described in the previous blog.
It was an off-by-one error. In the Room Class, the variable:
int day = 1
was wrongly initialized as 1.
It should be 0:
int day = 0
The Vertical Allocation Algorithm has the following advantages:
1. Reduces the probability of each Teacher teaching more than
two hours without a break. However, if a Teacher teaches
two subjects, a situation may arise where those 2 subjects may
coincidentally be allocated continuously in the same day. This
may result in the Teacher teaching more than 2 hours non-stop.
I will deal with this in a later algorithm development. For now,
I will just focus on simple allocation.
2. It prevents a subject from being allocated more than 2 hours per day.
To Do:
Experiment with allocation of each subject as fixed 2-hour slots.
IntiCas 026: Vertical Allocation Algorithm
Trying out Vertical Allocation Algorithm.
The Room object now encapsulates the job of allocating its rooms.
It does it by allocating the subjects vertically, i.e. if i have a subject
which needs 16 hours, what it will do is allocate all the 8 am slots
(Mon - Sat), then rolls-over to 9am slots (Mon - Sat) etc..
However, I encountered a new bug - it appears that there are
some gaps on the 7pm slots for Saturday as well as a gap on
the 9am slot for the second room.
To Do:
Fix the new bugs abovementioned.
Sunday, June 8, 2008
IntiCas 025: Major Redesign of Classes - Hit a brick wall
But hit a brick wall when trying to implement this
constraint:
Each subject limited to
2 hours per day
and limited to 6 hours per week.
The allocation algorithms proved to be more challenging
than I expected.
Friday, June 6, 2008
IntiCas 024: Can do Mon - Sat and Multiple Rooms
IntiCas 023: Does Mons and Tues
Thursday, June 5, 2008
IntiCas 022: Fixed Null Bug
The above shows subjects being allocated based
on the blog IntiCas Algorithm Experiment 003's
scenario However, it was also indicated that
the timetable that was generated for CSC666
was short by 1 hour and instead contained a
"null null" entry in the last slot.
The bug is now fixed and below is the code:
To Do:
Hopefully the algorithm above can form the template for
any future algorithms. I will next try to implement
allocation for all weeks instead of just Mondays. And
also try add additional constraints like a maximum
hours per day for each subject so that we will not end
up with 6 hours of the same subject per day.
Inticas 021: Result of Algorithm Experiment 003
Wednesday, June 4, 2008
Inticas Algorithm Experiment 003
Assuming I have the following subjects with the maximum hours
per week and assigned teachers:
And I have the following classrooms:
Write an algorithm that can automatically assign classroom slots
based upon the above requirements.
The only constraint here is that each subject should not exceed
6 hours per week.
Proposed Solution:
Inticas 020: Teacher/Subject Slots, Enabled Multiline Cells
Each slot will now display Subject & Teacher Initials.
Also enabled multi-line cells. Subject will display on one line and
Teacher initials on second line.
I had to increase the rowheight, by using a customised CellRenderer:
import javax.swing.JTextArea;
import javax.swing.table.TableCellRenderer;
import java.awt.Component;
import javax.swing.JTable;
class MultiLineCellRenderer extends JTextArea implements TableCellRenderer
{
public MultiLineCellRenderer() {
setLineWrap(true);
setWrapStyleWord(true);
setOpaque(true);
}
public Component getTableCellRendererComponent(JTable jTable,
Object obj, boolean isSelected, boolean hasFocus, int row,
int column)
{
setText((String)obj);
return this;
}
}
and also modified the RoomFrame constructor:
public RoomFrame()
{
initComponents();
mytable.setRowHeight(40);
for(int b=1;b<=12;b++)
{
mytable.getColumnModel().getColumn(b).setCellRenderer(
new MultiLineCellRenderer());
//mytable.getColumnModel().getColumn(b).setPreferredWidth(50);
}
}
To Do:
Classroom Allocation Algorithms by taking the subjects from the Subject class
and the Teacher info from the Teacher class saved in the SubjectSerialized
and TeacherSerialized files respectively.
Inticas 019: Autogeneration of TT, Saving TT
Added capability to save TimeTables.
Also tested with autogeneration of TT.
Tested the following case scenario:
Auto inserting a subject called CSC0,
CSC2, CSC3 and CSC4 on the 12 noon slots for all classrooms.
Works.
To Do:
1. To autoinsert Subjects and Teachers names from the
Subjects and Teachers Tables
(created by the use of Add Subjects and Add Teachers Frames).
2. Each allocated slot should have Subject name + Teacher name
- not just Subject name alone.
Tuesday, June 3, 2008
Inticas 018: JTree Autoupdates
User opens the Add Room Frame.
Added this to the MainFrame constructor:
myTimer = new Timer(15000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
InitTree();
And added this to the addRoomMenuItem:
if(!myTimer.isRunning()) myTimer.start();
To Do:
The next task is the heart of the system - and probably the most important one.
I will start implementing Classroom Allocation Algorithms.
Sunday, June 1, 2008
IntiCas 017: Cleaned Up JTree
Cleaned Up JTree.
Now only has Rooms.
Classrooms and Labs are being listed together - keeping the coding simple (for now).
JTree can automatically read RoomSerialized file when loaded.
It then initializes itself and adds nodes to show all available rooms.
To Do:
To let JTree autoupdate itself whenever user adds new rooms using the Add Room Frame.
IntiCas 016 : Enabled Adding of Rooms
User can enter room details and save it to RoomSerialized.txt file.
The AddRoomFrame also automatically reads this file when it loads.
ToDo:
To enable JTree to automatically read the RoomSerialized.txt file and automatically adds them as new nodes on the JTree.
IntiCas 015: Added JTree
Above is IntiCas 015.
Added JTree. On the left JScrollpane is the JTree.
ToDo:
To enable the JTree to automatically load the ClassroomSerialized.txt file and display all the available classrooms in the JTree nodes.
When user clicks on any node, the TimeTable for the selected node will be displayed in the right desktop Pane.