tpaviot / ProcessScheduler

A Python package for automatic and optimized resource scheduling
https://processscheduler.github.io/
GNU General Public License v3.0
59 stars 18 forks source link

find_another_solution question #6

Closed dreinon closed 3 years ago

dreinon commented 3 years ago

Why does the function of the title need a variable to be passed? If I just want all the possible solutions for a scenario, I should be able to just ask for it without any other restriction right?

Thanks :)

tpaviot commented 3 years ago

This is because there might be a huge number of solutions.

If you need to get all the solutions, just include the find_another_solution in a while loop.

dreinon commented 3 years ago

Good point Thomas, I tried doing that but what should I be passing the function for each interation? The function, as you were saying, isn't built to be called without passing parameters.

tpaviot commented 3 years ago

This function takes a variable for which you expect the result to get another solution. Let's imagine that the solver gives you a solution horizon=3, then if you call fin_another_solution(horizon), the solver will try to find a solution where the horizon is not 3. Actually, this function just adds one more constraint horizon!=3 and solves the system again. See https://github.com/tpaviot/ProcessScheduler/blob/ee70ca1fbdc3cbbe9816665cf8e5418a9e97f508/processscheduler/solver.py#L251

If you want to get all the possible solutions with different horizons, then:

solution = solver.solve()
while solution:
    solution = solver.find_another_solution(horizon)
dreinon commented 3 years ago

Question solved!