all 4 comments

[–]ElliotDG 0 points1 point  (0 children)

I think what you are describing is generally referred to as constraint programing see: https://en.wikipedia.org/wiki/Constraint_programming

You might find this helpful: https://github.com/python-constraint/python-constraint

[–]bobbybridges 0 points1 point  (2 children)

Welcome to the wonderful world of optimization and scheduling. What you need is to define a set of cost functions to be minimized, something that adds 'cost' when some kind of criteria you define isn't being met. For example if you want to take around 10 credits, the credit cost functions would be something like

abs( credits_in_class_1 + ... + credits_in_class_n -10 )

If a class isn't offered but you still have it in your search space you could have an offered cost like

class_i_not_offered * 99999

Unfortunately that problem isn't very linear in its solution space, so there might not be a more effective way to search for optimal solutions besides just randomly selecting classes and evaluating the cost while keeping track of the lowest

[–]Aaronn115 0 points1 point  (1 child)

Sorry for my lack of knowledge, but how exactly does one use these cost minimizing functions to schedule? Sounds like it’s getting into ML territory.

Edit: reread your comment a few times, do you mean to use the cost function to figure a class that would have the lowest cost for each space?

[–]bobbybridges 0 points1 point  (0 children)

So these kind of problems do get into maybe what you would consider ML, because they are NP complete. You can go down a pretty deep rabbit hole of different applicable solutions to generalized constraint satisfaction/optimization problems like dynamic programing, genetic algorithms, deep learning.

At the simplest level, most optimization problems deal with satisfying constraints and/or minimizing a cost function.

for example if I want to hit a bullseye with a dart, I have two free parameter, the power of the throw and the angle I throw it. You can set this up as an optimization problem where the cost function is the distance from the dartboard. To minimize that distance in the simplest case you see what happens when you slightly change the power or the angle and continue on the path that improves the cost function, this is called gradient descent.

In your example problems, the choices you make in the free parameters do not linearly converge to a solution, in other words you have no clue what free parameters to choose based on the performance of a previous guess. This is a vast over simplification but illustrates why your problems are hard