Skip to content

Commit

Permalink
fix: fix typing in wrapper.pyi (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 authored Apr 7, 2023
1 parent 89b00c8 commit 6cbb381
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 43 deletions.
27 changes: 26 additions & 1 deletion ilpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
from .wrapper import *
from .wrapper import * # noqa: F403

__version__ = "0.2.3"
__all__ = [ # noqa: F405
"Any",
"Binary",
"Constraint",
"Constraint",
"Constraints",
"Continuous",
"Cplex",
"Equal",
"GreaterEqual",
"Gurobi",
"Integer",
"LessEqual",
"Maximize",
"Minimize",
"Objective",
"Preference",
"Relation",
"Scip",
"Sense",
"Solution",
"Solver",
"Solver",
"VariableType",
]
70 changes: 31 additions & 39 deletions ilpy/wrapper.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ Any = Preference.Any
Scip = Preference.Scip
Gurobi = Preference.Gurobi
Cplex = Preference.Cplex

Continuous = VariableType.Continuous
Integer = VariableType.Integer
Binary = VariableType.Binary

Minimize = Sense.Minimize
Maximize = Sense.Maximize

LessEqual = Relation.LessEqual
Equal = Relation.Equal
GreaterEqual = Relation.GreaterEqual
LessEqual = Relation.LessEqual

class Solution:
def __init__(self, size: int) -> None: ...
Expand All @@ -43,62 +46,51 @@ class Solution:
def get_value(self) -> float: ...
def set_value(self, value: float) -> None: ...

class _Constraint:
class Objective:
def __init__(self, size: int = 0) -> None: ...
def set_constant(self, value: float) -> None: ...
def get_constant(self) -> float: ...
def set_coefficient(self, i: int, value: float) -> None: ...
def get_coefficients(self) -> list[float]: ...
def set_quadratic_coefficient(self, i: int, j: int, value: float) -> None: ...
def get_quadratic_coefficients(self) -> dict[tuple[int, int], float]: ...
def set_sense(self, sense: Sense) -> None: ...
def get_sense(self) -> Sense: ...
def resize(self, size: int) -> None: ...
def __len__(self) -> int: ...

class Constraint:
def __init__(self) -> None: ...
def set_coefficient(self, i: int, value: float) -> None: ...
def get_coefficients(self) -> dict[int, float]: ...
def set_quadratic_coefficient(self, i: int, j: int, value: float) -> None: ...
def get_quadratic_coefficients(self) -> dict[tuple[int, int], float]: ...
def set_relation(self, relation: Relation) -> None: ...
def set_value(self, value: float) -> None: ...
def get_relation(self) -> Relation: ...
def set_value(self, value: float) -> None: ...
def get_value(self) -> float: ...
def is_violated(self, solution: Solution) -> bool: ...

class LinearConstraint(_Constraint): ...

class QuadraticConstraint(_Constraint):
def set_quadratic_coefficient(self, i: int, j: int, value: float) -> None: ...

class LinearConstraints:
class Constraints:
def __init__(self) -> None: ...
def clear(self) -> None: ...
def add(self, constraint: LinearConstraint) -> None: ...
def add_all(self, constraints: LinearConstraints) -> None: ...
def add(self, constraint: Constraint) -> None: ...
def add_all(self, constraints: Constraints) -> None: ...
def __len__(self) -> int: ...

class _Objective:
def __init__(self, size: int = 0) -> None: ...
def __len__(self) -> int: ...
def resize(self, size: int) -> None: ...
def set_sense(self, sense: Sense) -> None: ...
def get_sense(self) -> Sense: ...
def set_coefficient(self, i: int, value: float) -> None: ...
def get_coefficients(self) -> list[float]: ...
def get_constant(self) -> float: ...
def set_constant(self, value: float) -> None: ...

class LinearObjective(_Objective): ...

class QuadraticObjective(_Objective):
def set_quadratic_coefficient(self, i: int, j: int, value: float) -> None: ...
def get_quadratic_coefficients(self) -> dict[tuple[int, int], float]: ...

class _Solver:
class Solver:
def __init__(
self,
num_variables: int,
default_variable_type: VariableType,
variable_types: dict[int, VariableType] | None = None,
preference: Preference = Preference.Any,
) -> None: ...
def set_constraints(self, constraints: LinearConstraints) -> None: ...
def set_objective(self, objective: Objective) -> None: ...
def set_constraints(self, constraints: Constraints) -> None: ...
def add_constraint(self, constraint: Constraint) -> None: ...
def set_timeout(self, timeout: float) -> None: ...
def set_optimality_gap(self, gap: float, absolute: bool = False) -> None: ...
def set_num_threads(self, num_threads: int) -> None: ...
def solve(self) -> tuple[Solution, str]: ...
def set_verbose(self, verbose: bool) -> None: ...

class LinearSolver(_Solver):
def set_objective(self, objective: LinearObjective) -> None: ...
def add_constraint(self, constraint: LinearConstraint) -> None: ...

class QuadraticSolver(_Solver):
def set_objective(self, objective: QuadraticObjective) -> None: ...
def add_constraint(self, constraint: QuadraticConstraint) -> None: ...
def solve(self) -> tuple[Solution, str]: ...
6 changes: 3 additions & 3 deletions ilpy/wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ cdef class Constraint:
def set_relation(self, relation):
self.p.setRelation(relation)

def set_value(self, value):
self.p.setValue(value)

def get_relation(self):
return Relation(self.p.getRelation())

def set_value(self, value):
self.p.setValue(value)

def get_value(self):
return self.p.getValue()

Expand Down

0 comments on commit 6cbb381

Please sign in to comment.