Skip to content

Commit

Permalink
More black formatting with new version.
Browse files Browse the repository at this point in the history
  • Loading branch information
sukritkalra committed Jan 31, 2024
1 parent 9a8515e commit 7f3d09d
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 8 deletions.
19 changes: 19 additions & 0 deletions schedulers/tetrisched/python/stubs/tetrisched_py/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Python API for TetriSched.
"""

from __future__ import annotations

import typing
Expand All @@ -22,6 +23,7 @@ class Partition:
"""
Adds the given quantity to this Partition.
"""

@typing.overload
def __init__(self, partitionId: int, partitionName: str) -> None:
"""
Expand All @@ -31,6 +33,7 @@ class Partition:
partitionId (int): The ID of this Partition.
partitionName (str): The name of this Partition.
"""

@typing.overload
def __init__(self, partitionId: int, partitionName: str, quantity: int) -> None:
"""
Expand All @@ -41,15 +44,18 @@ class Partition:
partitionName (str): The name of this Partition.
quantity (int): The quantity of this Partition.
"""

def __len__(self) -> int:
"""
Returns the number of Workers in this Partition.
"""

@property
def id(self) -> int:
"""
The ID of this Partition.
"""

@property
def name(self) -> str:
"""
Expand All @@ -61,21 +67,25 @@ class Partitions:
"""
Returns the Partition with the given ID (if exists).
"""

def __init__(self) -> None:
"""
Initializes an empty Partitions.
"""

def __len__(self) -> int:
"""
Returns the number of Partitions in this Partitions.
"""

def addPartition(self, partition: Partition) -> None:
"""
Adds a Partition to this Partitions.
Args:
partition (Partition): The Partition to add to this Partitions.
"""

def getPartitions(self) -> list[Partition]:
"""
Returns the Partitions in this Partitions.
Expand All @@ -102,17 +112,20 @@ class Scheduler:
maxDiscretization (int): The maximum discretization to use for dynamic discretization.
maxOccupancyThreshold (float): The maximum occupancy threshold to use for dynamic discretization.
"""

def exportLastSolverModel(self, fileName: str) -> None:
"""
Exports the model from the last invocation of the solver.
Args:
fileName (str): The filename to export the model to.
"""

def getLastSolverSolution(self) -> backends.SolverSolution:
"""
Retrieve the solution from the last invocation of the solver.
"""

def registerSTRL(
self,
expression: strl.Expression,
Expand All @@ -131,6 +144,7 @@ class Scheduler:
schedulerConfig (SchedulerConfig): The configuration for the scheduler.
timeRangeToGranularities (list): The time ranges to granularities to use for dynamic discretization.
"""

def schedule(self, currentTime: int) -> None:
"""
Invokes the solver to schedule the registered STRL expression.
Expand All @@ -144,31 +158,36 @@ class SchedulerConfig:
"""
Initializes an empty SchedulerConfig.
"""

@property
def newSolutionTimeMs(self) -> int | None:
"""
The new solution time to use for the solver.
"""

@newSolutionTimeMs.setter
def newSolutionTimeMs(self, arg0: int | None) -> None: ...
@property
def numThreads(self) -> int | None:
"""
The number of threads to use for the solver.
"""

@numThreads.setter
def numThreads(self, arg0: int | None) -> None: ...
@property
def optimize(self) -> bool:
"""
If True, the scheduler will optimize the STRL expression.
"""

@optimize.setter
def optimize(self, arg0: bool) -> None: ...
@property
def totalSolverTimeMs(self) -> int | None:
"""
The total solver time to use for the solver.
"""

@totalSolverTimeMs.setter
def totalSolverTimeMs(self, arg0: int | None) -> None: ...
22 changes: 22 additions & 0 deletions schedulers/tetrisched/python/stubs/tetrisched_py/backends.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Solver backends for the TetriSched Python API.
"""

from __future__ import annotations

import typing
Expand All @@ -25,17 +26,20 @@ class CPLEXSolver:
Args:
filename (str): The filename to export the model to.
"""

def getModel(self) -> tetrisched_py.model.SolverModel:
"""
Returns the underlying SolverModel abstraction used by this instance of CPLEXSolver.
"""

def solveModel(self) -> SolverSolution:
"""
Solves the CPLEX model.
Returns:
SolverSolution: The characteristics of the solution.
"""

def translateModel(self, solverConfig: SolverConfig) -> None:
"""
Translates the underlying SolverModel to a CPLEX model instance.
Expand All @@ -53,17 +57,20 @@ class GurobiSolver:
Args:
filename (str): The filename to export the model to.
"""

def getModel(self) -> tetrisched_py.model.SolverModel:
"""
Returns the underlying SolverModel abstraction used by this instance of GurobiSolver.
"""

def solveModel(self) -> SolverSolution:
"""
Solves the Gurobi model.
Returns:
SolverSolution: The characteristics of the solution.
"""

def translateModel(self, solverConfig: SolverConfig) -> None:
"""
Translates the underlying SolverModel to a Gurobi model instance.
Expand Down Expand Up @@ -152,25 +159,29 @@ class SolverConfig:
"""
Initializes an empty SolverConfig.
"""

@property
def newSolutionTimeMs(self) -> int | None:
"""
The total time to be spent between finding new incumbent solutions.
"""

@newSolutionTimeMs.setter
def newSolutionTimeMs(self, arg0: int | None) -> None: ...
@property
def numThreads(self) -> int | None:
"""
The total number of threads to allocate to the Solver.
"""

@numThreads.setter
def numThreads(self, arg0: int | None) -> None: ...
@property
def totalSolverTimeMs(self) -> int | None:
"""
The total time to be spent on the Solver.
"""

@totalSolverTimeMs.setter
def totalSolverTimeMs(self, arg0: int | None) -> None: ...

Expand All @@ -180,56 +191,67 @@ class SolverSolution:
"""
Check if the solution was valid.
"""

@property
def numCachedVariables(self) -> int | None:
"""
The number of variables that were cached before.
"""

@property
def numConstraints(self) -> int | None:
"""
The number of constraints in the model.
"""

@property
def numDeactivatedConstraints(self) -> int | None:
"""
The number of constraints that were generated but deactivated.
"""

@property
def numNonZeroCoefficients(self) -> int | None:
"""
The number of non-zero coefficients in the model.
"""

@property
def numSolutions(self) -> int | None:
"""
The number of solutions found by the solver.
"""

@property
def numUncachedVariables(self) -> int | None:
"""
The number of variables that were not cached before.
"""

@property
def numVariables(self) -> int | None:
"""
The number of variables in the model.
"""

@property
def objectiveValue(self) -> float | None:
"""
The objective value of the solution (if available).
"""

@property
def objectiveValueBound(self) -> float | None:
"""
The objective value of the bound retrieved from STRL (if available).
"""

@property
def solutionType(self) -> SolutionType:
"""
The type of solution returned by the solver.
"""

@property
def solverTimeMicroseconds(self) -> int:
"""
Expand Down
Loading

0 comments on commit 7f3d09d

Please sign in to comment.