Author Topic: Constraint Coding Question  (Read 2705 times)

Offline Simpsonboy77

  • Full Member
  • ***
  • Posts: 168
Constraint Coding Question
« on: February 25, 2010, 07:17:41 PM »
I'm writing a program to find the most optimal student schedule. I have a priority system in place to rank each schedule. This will evaluate each valid schedule based on *cringe* hard coded statements. I just have checkboxes for them.

I would like to expand this and bring out this wonderful option to the user but I am not entirely sure how. I thought of assigning a value to each time slot which would relate to how little you want that time to be used. ie. You do not want an early class but if you must have one you will take it.

This idea fails when you want m of n time slots open. The easiest one to visualize is lunch. My university has 3 blocks that are near lunch time, 10:00 - 11:30, 11:30 - 1:00 and 1:00 - 2:30. The user wants at least one of them the be left open, but does not care which one.

Now finally my question,
I am currently thinking of having a rule system where each rule when executed on a schedule will return how desirable it is (based on the user). Then the user can specify, ok I want rule 1 or rule 2 or rule 3, and rule 4 to be in effect. I have it written to take in each rule, but I am unsure how to pose it to the user in a friendly manner to do the boolean expression. This is written in Java using Swing to create the GUI.

my rule object has the following fields
desirability (int 0 means it is terrible to have open, 100 means it is excellent to have open)
start time
end time


Thanks, and if you got any questions, just ask.
My tutorials
Part 1
Part 2
Part 3

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3237
Constraint Coding Question
« Reply #1 on: February 25, 2010, 07:50:49 PM »
I don't think I understand the problem...
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline CK9

  • Administrator
  • Hero Member
  • *****
  • Posts: 6226
    • http://www.outpost2.net/~ck9
Constraint Coding Question
« Reply #2 on: February 25, 2010, 08:07:22 PM »
I read through it, and I can think of how it might be done on a PHP webpage, but I'm not goos with actual programs
CK9 in outpost
Iamck in runescape (yes, I still play...sometimes...)
srentiln in minecraft (I like legos, and I like computer games...it was only a matter of time...) and youtube...
xdarkinsidex on deviantart

yup, I have too many screen names

Offline Simpsonboy77

  • Full Member
  • ***
  • Posts: 168
Constraint Coding Question
« Reply #3 on: February 25, 2010, 09:04:11 PM »
Alright let me rephrase in simple terms.  I am writing a program to automatically find the optimal class schedule based on constraints.

Lets assume you want to tell the program that you always want to have a lunch, but you would prefer the 11:30 block over the 1pm or 10:00am block.

I have an idea how to do it, but its not elegant. I also want to be able to easily save the constraints to a file (this is the easier part though).

I don't really need code, just a general idea on how to approach this.  
My tutorials
Part 1
Part 2
Part 3

Offline CK9

  • Administrator
  • Hero Member
  • *****
  • Posts: 6226
    • http://www.outpost2.net/~ck9
Constraint Coding Question
« Reply #4 on: February 25, 2010, 09:33:30 PM »
okay, here's what I would do:

request the preference (in order of which time you would be most willing to least willing to have class in)  and store it in an array in that order)
set up a do loop that will re-initiate if a schedule conflict occurs.  In the loop, the integer that you increase with each itteration triggers a search for the classes that occur in a specific timeslot (for example: i starts at 0, the loop searches for classes that start at array, if conflicts with other classes occur, i++ and run the loop again).

Does this help?
CK9 in outpost
Iamck in runescape (yes, I still play...sometimes...)
srentiln in minecraft (I like legos, and I like computer games...it was only a matter of time...) and youtube...
xdarkinsidex on deviantart

yup, I have too many screen names

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3237
Constraint Coding Question
« Reply #5 on: February 25, 2010, 10:11:52 PM »
Quote
Alright let me rephrase in simple terms.  I am writing a program to automatically find the optimal class schedule based on constraints.
No, I understand what you want to do.  Why is this a problem?  Just have the user tell it what he/she wants.  If you want to simplify things, keep the 1-100 scale, but just present the user with some generalizations which correspond to some value on the scale.  For example, you could have "Very Desirable" (90), "Desirable" (75), "Neutral" (50), "Somewhat Undesirable" (25), or "Completely Undesirable" (10).  Allow the user to mark one or two things as "Must-Have" (100) and "Must Not Have" (1).  Then for each block the program can pick the lowest value and mark that as "free time".  If there are ties choose randomly.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Simpsonboy77

  • Full Member
  • ***
  • Posts: 168
Constraint Coding Question
« Reply #6 on: February 27, 2010, 04:11:45 PM »
The problem is how to get the information from the user. Every idea i think of is complicated. Basically I just need an idea of a layout and what type of input fields.

I can prioritize all the other times juts fine. Its when I try to bring something out like "one of these 3 times must be open" where it gets tricky. I might just code it how I have planned, and then post it. This way you can comment on how it is hard to use.
My tutorials
Part 1
Part 2
Part 3

Offline CK9

  • Administrator
  • Hero Member
  • *****
  • Posts: 6226
    • http://www.outpost2.net/~ck9
Constraint Coding Question
« Reply #7 on: February 27, 2010, 04:24:00 PM »
I would use radio buttons to rank each option
CK9 in outpost
Iamck in runescape (yes, I still play...sometimes...)
srentiln in minecraft (I like legos, and I like computer games...it was only a matter of time...) and youtube...
xdarkinsidex on deviantart

yup, I have too many screen names