/**
 * @file tsp_solver.cpp
 * @author Jan Holáň, xholan11 (xholan11@vutbr.cz)
 * @brief translated with gcc version 12.2.1
 * @version 0.1
 * @date 2023-05-01
 * 
 * @copyright Copyright (c) 2023
 * 
 */

#ifndef _TSP_SOLVER_H_
#define _TSP_SOLVER_H_

#include "WarehousePickingOpt.h"

/// @brief namespace covering all functions for solving tsp problem (sorting items in cart)
namespace tsp_solver
{
    /// @brief sort item in cart - TSP problem - to create the shortest path through all of them using nearest neighbour heuristics
    /// @param item_vect cart which items should be sorted
    /// @param warehouse warehouse instance
    /// @param res_vect out-vector with result - sorted items to the nearest path
    /// @return estimated walked distance from the beginning to the beginning
    int nearestNeighbour(vector<CartOItem> item_vect, Warehouse &warehouse, vector<CartOItem> *res_vect, SECTOR_ADDR_T starting_point, SECTOR_ADDR_T end_point);

    /// @brief brute force implementation for solver of TSP problem
    /// @param item_vect cart which items should be sorted
    /// @param warehouse warehouse instance
    /// @param res_vect out-vector with result - sorted items to the nearest path
    /// @return estimated walked distance from the beginning to the beginning
    int bruteForce(vector<CartOItem> item_vect, Warehouse &warehouse, vector<CartOItem> *res_vect, SECTOR_ADDR_T starting_point, SECTOR_ADDR_T end_point);

    /// @brief just measuring distance between given points
    /// @param item_vect given points
    /// @param warehouse warehouse instance with measuring implementation
    /// @return distance from first item to the last
    int justMeasureDistance(vector<CartOItem> item_vect, Warehouse &warehouse, SECTOR_ADDR_T starting_point, SECTOR_ADDR_T end_point);

    /// @brief greedy algorithm implementation for TSP solving
    /// @param item_vect cart which items should be sorted
    /// @param warehouse warehouse instance
    /// @param res_vect out-vector with result - sorted items to the nearest path
    /// @return estimated walked distance from the beginning to the beginning
    int greedyAlgorithm(vector<CartOItem> item_vect, Warehouse &warehouse, vector<CartOItem> *res_vect, SECTOR_ADDR_T starting_point, SECTOR_ADDR_T end_point);
    int greedyAlgorithmTmp(vector<CartOItem> item_vect, Warehouse &warehouse, vector<CartOItem> *res_vect, SECTOR_ADDR_T starting_point, SECTOR_ADDR_T end_point);
};

#endif