KindAlien commited on
Commit
a935bbc
·
verified ·
1 Parent(s): 81bc3c3

Update solver.py

Browse files
Files changed (1) hide show
  1. solver.py +4 -1
solver.py CHANGED
@@ -2,6 +2,7 @@
2
 
3
  from typing import List, Dict, Optional, Any, Tuple
4
  from ortools.sat.python import cp_model
 
5
 
6
  from models import Task, Faculty, Section, Room
7
  from constraint_engine import ConstraintEngine
@@ -24,10 +25,12 @@ class TimetableSolver:
24
  enable_soft_constraints: bool = True,
25
  soft_constraint_weights: Dict[str, int] = None,
26
  log_search_progress: bool = True,
27
- num_workers: int = 8,
28
  slm_constraints: List[Dict[str, Any]] = None,
29
  scheduling_rules: List[Dict[str, Any]] = None,
30
  ) -> Tuple[str, Optional[Dict[str, Any]]]:
 
 
31
 
32
  # 1. Hard constraints
33
  print("Initializing Constraint Engine...")
 
2
 
3
  from typing import List, Dict, Optional, Any, Tuple
4
  from ortools.sat.python import cp_model
5
+ import os
6
 
7
  from models import Task, Faculty, Section, Room
8
  from constraint_engine import ConstraintEngine
 
25
  enable_soft_constraints: bool = True,
26
  soft_constraint_weights: Dict[str, int] = None,
27
  log_search_progress: bool = True,
28
+ num_workers: int = None,
29
  slm_constraints: List[Dict[str, Any]] = None,
30
  scheduling_rules: List[Dict[str, Any]] = None,
31
  ) -> Tuple[str, Optional[Dict[str, Any]]]:
32
+ if num_workers is None:
33
+ num_workers = os.cpu_count() or 8
34
 
35
  # 1. Hard constraints
36
  print("Initializing Constraint Engine...")