optimal-loc


Nameoptimal-loc JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://github.com/sinan-demirhan/optimal-loc
SummaryA python project which finds the optimal N locations in a given area according to the given location inputs. This package can be used for business or individual needs.
upload_time2023-06-21 13:16:04
maintainer
docs_urlNone
authorSinan Demirhan
requires_python>=3.7,<4.0
licenseMIT
keywords optimalloc optimal_loc optimal-loc optimal optimal location optimal location finder
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## What is it?

The OptimalLoc package is a Python library designed to provide a solution for finding optimal locations based on various needs such as transportation and logistics, urban planning, retail, healthcare, and emergency services. The package utilizes a mixed integer linear optimization algorithm to calculate the optimal locations based on input demands and a specified number of location points.

## Main Features

- Hexagon mapping: The package uses the Uber h3 library to map locations onto hexagons on a map. This allows for efficient optimization calculations by reducing the number of data points involved.
- Event frequency calculation: The package calculates the frequency of events in each hexagonal region based on the provided input data. This information is used in the optimization algorithm to determine the optimal locations.
- Distance data management: The package includes functionality to create and read distance data between pairs of hexagonal regions. This data can be stored in a database, such as MongoDB, or as a dataframe.
- Optimization algorithm: The package utilizes a mixed integer linear optimization algorithm, implemented using the pulp library, to determine the optimal locations based on the given demands and the desired number of location points.
- Visualization: The package provides a frontend app built with Streamlit to visualize the optimal results on a map. Users can interact with the app to analyze and understand the optimal locations.

## Purpose of the Package

The OptimalLoc package aims to assist various industries, including logistics, retail, and emergency services, in optimizing their operations by identifying the best locations for their needs. By finding the optimal locations, organizations can improve efficiency, reduce costs, and enhance their overall performance.

## Getting Started

### Installation

To install the OptimalLoc package, you can use pip, the package installer for Python:
```bash
pip install optimal-loc
```

### Usage

To use the OptimalLoc package for finding optimal locations, follow the steps below:

1. Import the `OptimalLoc` class from the package:

    ```bash
    import optimal_loc
    ```

2. Create an instance of the `OptimalLoc` class:

    ```bash
    sol = optimal_loc.OptimalLoc()
    ```

3. Prepare your input data:
   - Load your data into a pandas DataFrame, ensuring it includes the required columns for latitude and longitude information.
   - Clean and preprocess the data as needed.

4. Create hexagon distance data:
   - Call the `create_hexagon_distance_data` method of the `OptimalLoc` instance, providing your preprocessed data and specifying the hexagon size ('small', 'medium', or 'big').
   - This step will calculate the hexagons on which the points in your data fall and create the necessary data to calculate distances between these hexagons.

    Example:
    ```bash
    sol.create_hexagon_distance_data(data, 'medium')
    ```

5. Read the distances:
   - If you have a large distance dataset, you can store it in a MongoDB database and read it using the `read_distances_from_mongodb` method.
   - Alternatively, you can directly read the distance data from a dataframe using the `read_distances` method.

    Example (reading from MongoDB):
    ```bash
    sol.read_distances_from_mongodb(mongo_client=MongoClient,
                                    mongo_database_name="db_name",
                                    mongo_collection_name="collection_name")
    ```

    Example (reading from a dataframe):
    ```bash
    sol.read_distances(read_from_dataframe=True, distance_dataframe=distance_data)
    ```

6. Calculate optimal locations:
   - Call the `calculate_optimal_locations` method of the `OptimalLoc` instance, specifying the number of desired optimal locations and providing the distance and frequency data.
   - This step will run the mixed integer linear optimization algorithm and calculate the optimal points or hexagon regions.

    Example:
    ```bash
    sol.calculate_optimal_locations(number_of_loc=5)
    ```

7. Access the results:
   - After running the optimization algorithm, the optimal and supply data will be available in the `optimal_data` and `supply_data` attributes of the `OptimalLoc` instance, respectively.

    Example:
    ```bash
    optimal_results = sol.optimal_data
    supply_results = sol.supply_data
    ```

8. Visualize the results:
   - To visualize the optimal results on a map, you can call the `visualize` function from the `optimal_loc.bash_command` module.

    Example:
    ```bash
    optimal_loc.visualize()
    ```

9. Explore and analyze the optimal locations using the provided Streamlit frontend app.

   Example:
   - Open the app in a web browser using the displayed URL.
   - Interact with the app to analyze the optimal locations visually and perform further analyses.

By following these steps, you can utilize the OptimalLoc package to find optimal locations for various applications, such as transportation and logistics, urban planning, retail, healthcare, and emergency services.


## Contribution
Contributions are welcome.
Notice a bug let us know.

## Author
+ Main Maintainer: Sinan Demirhan (SDemirhan)
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sinan-demirhan/optimal-loc",
    "name": "optimal-loc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "optimalLoc,optimal_loc,optimal-loc,optimal,optimal location,optimal location finder",
    "author": "Sinan Demirhan",
    "author_email": "sdemirhan1320@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b7/48/c22e483782e4b37b8e18a572afff42a1f0ad04cfc46aa584bcc96a510b70/optimal_loc-0.1.7.tar.gz",
    "platform": null,
    "description": "## What is it?\n\nThe OptimalLoc package is a Python library designed to provide a solution for finding optimal locations based on various needs such as transportation and logistics, urban planning, retail, healthcare, and emergency services. The package utilizes a mixed integer linear optimization algorithm to calculate the optimal locations based on input demands and a specified number of location points.\n\n## Main Features\n\n- Hexagon mapping: The package uses the Uber h3 library to map locations onto hexagons on a map. This allows for efficient optimization calculations by reducing the number of data points involved.\n- Event frequency calculation: The package calculates the frequency of events in each hexagonal region based on the provided input data. This information is used in the optimization algorithm to determine the optimal locations.\n- Distance data management: The package includes functionality to create and read distance data between pairs of hexagonal regions. This data can be stored in a database, such as MongoDB, or as a dataframe.\n- Optimization algorithm: The package utilizes a mixed integer linear optimization algorithm, implemented using the pulp library, to determine the optimal locations based on the given demands and the desired number of location points.\n- Visualization: The package provides a frontend app built with Streamlit to visualize the optimal results on a map. Users can interact with the app to analyze and understand the optimal locations.\n\n## Purpose of the Package\n\nThe OptimalLoc package aims to assist various industries, including logistics, retail, and emergency services, in optimizing their operations by identifying the best locations for their needs. By finding the optimal locations, organizations can improve efficiency, reduce costs, and enhance their overall performance.\n\n## Getting Started\n\n### Installation\n\nTo install the OptimalLoc package, you can use pip, the package installer for Python:\n```bash\npip install optimal-loc\n```\n\n### Usage\n\nTo use the OptimalLoc package for finding optimal locations, follow the steps below:\n\n1. Import the `OptimalLoc` class from the package:\n\n    ```bash\n    import optimal_loc\n    ```\n\n2. Create an instance of the `OptimalLoc` class:\n\n    ```bash\n    sol = optimal_loc.OptimalLoc()\n    ```\n\n3. Prepare your input data:\n   - Load your data into a pandas DataFrame, ensuring it includes the required columns for latitude and longitude information.\n   - Clean and preprocess the data as needed.\n\n4. Create hexagon distance data:\n   - Call the `create_hexagon_distance_data` method of the `OptimalLoc` instance, providing your preprocessed data and specifying the hexagon size ('small', 'medium', or 'big').\n   - This step will calculate the hexagons on which the points in your data fall and create the necessary data to calculate distances between these hexagons.\n\n    Example:\n    ```bash\n    sol.create_hexagon_distance_data(data, 'medium')\n    ```\n\n5. Read the distances:\n   - If you have a large distance dataset, you can store it in a MongoDB database and read it using the `read_distances_from_mongodb` method.\n   - Alternatively, you can directly read the distance data from a dataframe using the `read_distances` method.\n\n    Example (reading from MongoDB):\n    ```bash\n    sol.read_distances_from_mongodb(mongo_client=MongoClient,\n                                    mongo_database_name=\"db_name\",\n                                    mongo_collection_name=\"collection_name\")\n    ```\n\n    Example (reading from a dataframe):\n    ```bash\n    sol.read_distances(read_from_dataframe=True, distance_dataframe=distance_data)\n    ```\n\n6. Calculate optimal locations:\n   - Call the `calculate_optimal_locations` method of the `OptimalLoc` instance, specifying the number of desired optimal locations and providing the distance and frequency data.\n   - This step will run the mixed integer linear optimization algorithm and calculate the optimal points or hexagon regions.\n\n    Example:\n    ```bash\n    sol.calculate_optimal_locations(number_of_loc=5)\n    ```\n\n7. Access the results:\n   - After running the optimization algorithm, the optimal and supply data will be available in the `optimal_data` and `supply_data` attributes of the `OptimalLoc` instance, respectively.\n\n    Example:\n    ```bash\n    optimal_results = sol.optimal_data\n    supply_results = sol.supply_data\n    ```\n\n8. Visualize the results:\n   - To visualize the optimal results on a map, you can call the `visualize` function from the `optimal_loc.bash_command` module.\n\n    Example:\n    ```bash\n    optimal_loc.visualize()\n    ```\n\n9. Explore and analyze the optimal locations using the provided Streamlit frontend app.\n\n   Example:\n   - Open the app in a web browser using the displayed URL.\n   - Interact with the app to analyze the optimal locations visually and perform further analyses.\n\nBy following these steps, you can utilize the OptimalLoc package to find optimal locations for various applications, such as transportation and logistics, urban planning, retail, healthcare, and emergency services.\n\n\n## Contribution\nContributions are welcome.\nNotice a bug let us know.\n\n## Author\n+ Main Maintainer: Sinan Demirhan (SDemirhan)",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python project which finds the optimal N locations in a given area according to the given location inputs. This package can be used for business or individual needs.",
    "version": "0.1.7",
    "project_urls": {
        "Homepage": "https://github.com/sinan-demirhan/optimal-loc",
        "Repository": "https://github.com/sinan-demirhan/optimal-loc"
    },
    "split_keywords": [
        "optimalloc",
        "optimal_loc",
        "optimal-loc",
        "optimal",
        "optimal location",
        "optimal location finder"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7574ef441e8cdbe4626342b974d084d71b1c38b9cbd996fe1c117cb3518b7c69",
                "md5": "e1b31c47bbc7195d131d70f810257cd5",
                "sha256": "ea3508b29fd68b8f7e2485c7089ac94e4144fd5b9cc01cd895e0063e52f0f656"
            },
            "downloads": -1,
            "filename": "optimal_loc-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e1b31c47bbc7195d131d70f810257cd5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 122352,
            "upload_time": "2023-06-21T13:16:02",
            "upload_time_iso_8601": "2023-06-21T13:16:02.477298Z",
            "url": "https://files.pythonhosted.org/packages/75/74/ef441e8cdbe4626342b974d084d71b1c38b9cbd996fe1c117cb3518b7c69/optimal_loc-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b748c22e483782e4b37b8e18a572afff42a1f0ad04cfc46aa584bcc96a510b70",
                "md5": "e28bba154ae0f62da7e0eadbc1fa24ea",
                "sha256": "5ae0513f3bd5330f8a00d338d6b9149d8b2294477e90fdb52d9e3781c047685a"
            },
            "downloads": -1,
            "filename": "optimal_loc-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "e28bba154ae0f62da7e0eadbc1fa24ea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 123685,
            "upload_time": "2023-06-21T13:16:04",
            "upload_time_iso_8601": "2023-06-21T13:16:04.449590Z",
            "url": "https://files.pythonhosted.org/packages/b7/48/c22e483782e4b37b8e18a572afff42a1f0ad04cfc46aa584bcc96a510b70/optimal_loc-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-21 13:16:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sinan-demirhan",
    "github_project": "optimal-loc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "optimal-loc"
}
        
Elapsed time: 0.07824s