Closed leonlan closed 4 months ago
I'm not satisfied with this method:
def add_constraint(
self,
first: Operation,
second: Operation,
constraint: Constraint,
):
"""
Adds a precedence constraint between two operations.
Parameters
----------
first
First operation.
second
Second operation.
constraint
Constraint between the first and the second operation.
"""
op1 = self._id2op[id(first)]
op2 = self._id2op[id(second)]
self._constraints[op1, op2].append(constraint)
It doesn't feel very intuitive. Instead I think we should split this up for every constraint that we have.
def add_end_before_start(self, first: Operation, second: Operation):
op1 = self._id2op[id(first)]
op2 = self._id2op[id(second)]
self._constraints[op1, op2].append(Constraint.END_BEFORE_START)
def add_start_before_end(self, first: Operation, second: Operation):
op1 = self._id2op[id(first)]
op2 = self._id2op[id(second)]
self._constraints[op1, op2].append(Constraint.START_BEFORE_END)
def add_previous(self, first: Operation, second: Operation):
op1 = self._id2op[id(first)]
op2 = self._id2op[id(second)]
self._constraints[op1, op2].append(Constraint.PREVIOUS)
def add_same_resource(self, first: Operation, second: Operation):
op1 = self._id2op[id(first)]
op2 = self._id2op[id(second)]
self._constraints[op1, op2].append(Constraint.SAME_RESOURCE)