// Structure for Point, Geo coordinates can be represented with it typedef struct { double X, Y; }Point; // Structure to keep cost, distance and traveltime. If distance/ traveltime is missing, there may be a negative flag typedef struct { double cost, distance, traveltime; }CostPack; // Class for holding vehicle information which consist of capacity, and cost_per_km // For first version we will use homogeneous cost class CVehicleInfo { public: CVehicleInfo(); ~CVehicleInfo(); bool init(); bool loadUnit(int lUnit); bool unloadUnit(int lUnit); int getCapacity(); void setCapacity(int capacity); int getId(); void setId(int id); double getCostPerKM(); void setCostPerKM(double cost); CVehicleInfo( CVehicleInfo const& ); CVehicleInfo& operator = (const CVehicleInfo& vehicleInfo); private: int m_iCapacity; int m_iCurrentLoad; int m_iVehicleId; double m_dCostPerKM; }; // Class to represent Orders. Each order is consist of open_time, close_time and sevice_time, its location and number of units ordered. class COrderInfo { public: COrderInfo(); ~COrderInfo(); int getOpenTime(); void setOpenTime(int openTime); int getCloseTime(); void setCloseTime(int closeTime); int getServiceTime(); void setServiceTime(int serviceTime); int getOrderUnit(); void setOrderUnit(int orderUnit); Point getOrderLocation(); void setOrderLocation(Point location); COrderInfo( COrderInfo const& ); COrderInfo& operator = (const COrderInfo& solution); private: int m_iOrderOpenTime; int m_iOrderCloseTime; int m_iOrderServiceTime; int m_iOrderUnitCount; int m_iOrderId; Point m_ptOrderLocation; }; // Class to represent Depot information. Each depot will have it's Open_Time and Close_Time. The Depot that will open earliest will have open time 0 // and all other time will be normalized with respect to it. For the first version there will be only one depot class CDepotInfo { public: CDepotInfo(); ~CDepotInfo(); int getOpenTime(); void setOpenTime(int openTime); int getCloseTime(); void setCloseTime(int closeTime); int getDepotId(); void setDepotId(int id); Point getDepotLocation(); void setDepotLocation(Point location); CDepotInfo( CDepotInfo const& ); CDepotInfo& operator = (const CDepotInfo& solution); private: int m_iDepotOpenTime; int m_iDepotClosTime; int m_iDepotId; Point m_ptDepotLocation; }; // Class to represent information of a Tour. A Tour starts from a depot and ends in a depot. On the way it serves several orders. // Each Tour has a vehicle ID and the list of Orders it serves in appropriate order. It also has the total Distance, Cost and Time assciated. class CTourInfo { public: CTourInfo(); ~CTourInfo(); init(); int getVehicleId(); void setVehicleId(int vehicleId); int getStartDepot(); void setStartDepot(int depotId); int getEndDepot(); void setEndDepot(int depotId); bool addCustomer(int customerId); std::vector getOrderVecotor(); CTourInfo( CTourInfo const& ); CTourInfo& operator = (const CTourInfo& solution); private: int m_iVehicleId; int m_iStartDepotId; int m_iEndDepotId; int m_iOrdersServed; std::vector m_viOrderIds; double m_dTotalCost; double m_dTotalDistance; double m_dTotalTraveltime; }; // This class will represent a solution of a VRP problem. A solution will be consist of multiple tour. // It also contains the number of vehicle used, number of orders served and total cost, distance and traveltime. class CSolutionInfo { public: CSolutionInfo(); ~CSolutionInfo(); int getVehicleUsed(); bool addTour(CTourInfo& tour); double getTotalCost(); double getTotalDistance(); double getTotalTravelTime(); std::vector getTourInfoVector(); CTourInfo( CTourInfo const& ); CTourInfo& operator = (const CTourInfo& solution); private: std::vector m_vtourAll; int m_iVehicleUsed; int m_iOrdersServed; int m_iTotalOrders; double m_dTotalCost; double m_dTotalDistance; double m_dTotalTraveltime; } // This is the main class that will solve the VRP problem. It will use the previous classes to represent the problem and the solution. // It will also have pre generated point to point distance/ cost/ traveltime information in maps. class CVRPSolver { public: CVRPSolver(); ~CVRPSolver(); bool init(); bool addDepot(CDepotInfo depotInfo); bool addOrder(COrderInfo orderInfo); bool addVehicle(CVehicleInfo vehicleInfo); CostPack getOrderToOrderCost(int firstOrder, int secondOrder); CostPack getDepotToOrderCost(int depotId, int orderId); CostPack getOrderToOrderCost(int depotId, int orderId); bool addOrderToOrderCost(int firstOrder, int secondOrder, CostPack cost); bool addDepotToOrderCost(int depotId, int orderId, CostPack cost); bool addOrderToOrderCost(int depotId, int orderId, CostPack cost); bool solveVRP(std::string& strError); bool getSolution(CSolution *solution, std::string& strError); private: bool m_bIsReadyToSolve; std::vector m_vVehicleInfos; std::vector m_vOrderInfos; std::vector m_vDepotInfos; std::map m_mapCustomerIdToIndex; std::map m_mapVehicleIdToIndex; std::map m_mapDepotIdToIndex; std::map, CostPack> m_mapOrderToOrderCost; std::map, CostPack> m_mapDepotToOrderrCost; std::map, CostPack> m_mapOrderToDepotCost; bool m_bIsSoultionReady; CSolutionInfo m_solutionFinal; }