Beispiel #1
0
    def test_clustered_ordering_noerror(self):
        c = KMeansBasedBarsDivision()
        filePath = os.path.dirname(os.path.abspath(__file__))

        with open(
                os.path.join(
                    os.path.join(
                        os.path.split(
                            os.path.split(
                                os.path.split(
                                    os.path.split(filePath)[0])[0])[0])[0],
                        "TestData"), "testModelDataWithOneCrane.json"),
                "r") as dataFile:
            dataFile.seek(0, 0)
            data = json.loads(dataFile.read())
            if not "modelData" in data or not "cranes" in data:
                self.fail("Bad json implemented")
            parser = AdvanceSteelModelParser()
            pm = parser.ParseProjectModel(data[ec.TagCraneOptModelData])
            cranes = [TowerCraneData(data[ec.TagCraneOptCranes][0])] * 3
            sd = SiteData(pm, cranes)
            centers = [
                np.array([bar.CenterPoint.X, bar.CenterPoint.Y])
                for bar in pm.SteelAnalyticalModel.Bars.values()
            ]
            c.ProhibitedRegion = sd.ModelPolygon
            c.Radiuses = [cr.maxLength for cr in cranes]
            res = c.FindCenters(centers, 3)
            # Build model bars dependency graph
            BarDependencyChecker.buildDependencyGraph(sd)
            order = ConstructionOrdering.GetConstructionOrderClustered(
                sd.dependencies, list(sd.Bars.values()), res[2])
Beispiel #2
0
def calc_model_buildordercluster():
    """Generates pre-order for building whole structure with clustering bars between multiple cranes"""
    # Check whether model data is in input
    if not request.json or not ec.TagCraneOptModelData in request.json or not ec.TagCraneOptCranes in request.json:
        abort(400)

    # Parse project model from JSON
    client = ""
    if ec.ArgCraneOptClient in request.args:
        client = request.args.get(ec.ArgCraneOptClient,
                                  ec.ValCommonClientAdvanceSteel)
    parser = eutils.GetParserByClientType(client,
                                          ec.ValCommonClientAdvanceSteel)
    pm = parser.ParseProjectModel(request.json[ec.TagCraneOptModelData])
    cranes = [
        eutils.GetCraneByType(crane)
        for crane in request.json[ec.TagCraneOptCranes]
    ]
    modelData = SiteData(pm, cranes)

    # Build model bars dependency graph
    BarDependencyChecker.buildDependencyGraph(modelData)
    PanelDependencyChecker.buildDependencyGraph(modelData)

    # Do bars clustering
    from Optimization.Clustering.KMeansBasedBarsDivision import KMeansBasedBarsDivision
    clusterer = KMeansBasedBarsDivision()
    centers = [
        np.array([bar.CenterPoint.X, bar.CenterPoint.Y])
        for bar in pm.SteelAnalyticalModel.Bars.values()
    ]
    clusterer.ProhibitedRegion = modelData.ModelPolygon
    clusterer.Radiuses = [cr.maxLength for cr in cranes]
    resClustering = clusterer.FindCenters(centers, len(cranes))

    # Get construction order usin the graph
    res = ConstructionOrdering.GetConstructionOrderClustered(
        modelData.dependencies, list(modelData.ConstructionObjects.values()),
        resClustering[2])

    # Return order
    return jsonify({ec.OutTagConstrOrderOrder: res}), 200