コード例 #1
0
    def __init__(self, data: Problem, savePlotData=False) -> None:
        """ Read in the problem data and store of use."""
        # Take the order dict and make a List of tuples. The first
        # index is typ type, "biker", "REST" or "CUST"
        self.bikerStart = data.bikers()
        self.nrBikers = len(self.bikerStart)
        self.graph = data.graph()
        self.nrNodes = self.graph.node_count()
        self.costMatrix = (-1 * np.ones(
            (self.nrNodes, self.nrNodes)) + np.eye(self.nrNodes))
        self.nodeDicts = [dict(), dict()]  # type: List[Dict[int, Node]]
        self.orders = data.orders()

        self.nrOrders = 0
        for o in range(len(self.orders)):
            self.nodeDicts[0][self.nrOrders] = self.orders[o][0]
            self.nodeDicts[1][self.nrOrders] = self.orders[o][1]
            self.nrOrders += 1

        self.solution = dict()  # type: Dict[int, List[Tuple[int, int]]]
        self.costOfRoutes = None
        # bikers1, biker2
        self.searchOrder = []  # type: List[Tuple[int, int]]
        for i in range(self.nrBikers):
            self.solution[i] = []
            for j in range(i + 1, self.nrBikers):
                self.searchOrder.append((i, j))
        self.Ts = None  # type: float
        self.Tf = None  # type: float
        self.Tr = None  # type: float
        self.alpha = None  # type: int
        self.gamma = None  # type: int
        self.bestSolution = None  # type: Dict[int, List[Tuple[int, int]]]
        self.bestCost = None
        self.bestCostOfRoutes = None
        self.savePlotData = savePlotData
        if savePlotData:
            self.costData = []
            self.bestCostData = []
            self.tempData = []