Selaa lähdekoodia

Uwzglednienie tras z poprzedniej petli grupy przez zastosowanie triku z aliasem

a.binder 9 vuotta sitten
vanhempi
commit
f33dad0ad0

+ 116 - 69
SE/dev/php-cli/edge_paths_with_PE_controll.xsl

@@ -16,9 +16,11 @@
     <xsl:param name="Cable_Price" select="10"/>
     
     <xsl:param name="edge_paths_with_PE.xml"/>
+    <xsl:param name="edge_paths_with_PE_controll_temp" select="'edge_paths_with_PE_controll_temp'"/> <!-- cache do przekazywani danych z petli-->
+    <xsl:param name="edge_paths_with_PE_controll_temp.alias" select="'edge_paths_with_PE_controll_temp.alias'" />
     
     <!-- bedziemy od najdluzszej drogi starac sie rozmiescic PE w oparciu o rozmieszczenie klientow oraz odleglosci  -->
-    
+    <xsl:variable name="poprzednie_odpalam_liczenie_or_nie"/>
     
     
     <xsl:template match="edge_joins_filled_paths">
@@ -33,68 +35,29 @@
                 </Path>
             </xsl:for-each>
         </xsl:variable>
-        <xsl:variable name="edge_paths_with_PE_controll">
+       
             <edge_paths_with_PE_controll>
                <xsl:apply-templates select="$edge_joins_filled_paths_len" mode="PointMatrixGroup"/>
             </edge_paths_with_PE_controll>
-        </xsl:variable>
-            <xsl:copy-of select="$edge_paths_with_PE_controll"/>
-        <xsl:result-document href="edge_paths_with_PE.xml">
-             <xsl:apply-templates select="$edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml"/>
-        </xsl:result-document>
-    </xsl:template>
-    
-    
-    <xsl:template match="edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml">
-        <PE_candidates_dump>
-            <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
-        </PE_candidates_dump>
-    </xsl:template>
-    
-    <xsl:template match="Path" mode="edge_paths_with_PE.xml">
-        <LINESTRING>
-            <xsl:attribute name="ID_Way" select="@id"/>
-            <xsl:attribute name="Count"  select="@Count"/>
-            <xsl:attribute name="ID_Point_count" select="@Points_cnt"/>
-            <xsl:attribute name="distance"/>
-            <xsl:attribute name="dumb_frequency" select="''"/>
-            <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
-        </LINESTRING>
-    </xsl:template>
-    
-    <xsl:template match="PointMatrixGroupPE" mode="edge_paths_with_PE.xml">
         
-        <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
-    </xsl:template>
-    
-    <xsl:template match="PointMatrixGroup" mode="edge_paths_with_PE.xml">
-        <!--<test_matrux><xsl:copy-of select="."></xsl:copy-of></test_matrux>-->
-        <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
-    </xsl:template>
-    
-    <xsl:template match="odpalam_liczenie" mode="edge_paths_with_PE.xml">
-        <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
-    </xsl:template>
-    <xsl:template match="koniec_wariantow" mode="edge_paths_with_PE.xml">
-        <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
-    </xsl:template>
-    
-    <xsl:template match="bp:Path_Point" mode="edge_paths_with_PE.xml">
-        <xsl:copy-of select="."/>
+        <!--<xsl:result-document href="edge_paths_with_PE.xml">
+             <xsl:apply-templates select="$edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml"/>
+        </xsl:result-document>-->
     </xsl:template>
     
-    <xsl:template match="variant" mode="edge_paths_with_PE.xml"/>
     
     
     <xsl:template match="Path" mode="PointMatrixGroup">
         <Path>
             <xsl:variable name="edge_joins_filled_path" select=" doc(concat('edge_joins_filled_paths/edge_joins_filled_paths.',@id,'.xml'))"/>
             <xsl:attribute name="id" select="@id"/>
+            <xsl:variable name="ID_Way" select="@id"/>
             <xsl:attribute name="Points_cnt" select="@Points_cnt"/>
             <xsl:variable name="Points_cnt" select="@Points_cnt"/>
             <xsl:attribute name="len" select="@len"/>
             <xsl:attribute name="Count" select="count($edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString)"/>
             <xsl:variable name="len" select="@len"/>
+            
         <!--<xsl:variable name="edge_joins_filled_paths" select="collection( 'edge_joins_filled_paths?select=*.xml;recurse=yes')"/>-->
         
         <!--<EdgeWayJoinsPair>
@@ -234,24 +197,61 @@
                                     </bp:Path_Point>
                                 </xsl:for-each>
                         </xsl:variable>
+                    
+                    
+                    <!-- potrzebuje wywolac petle raz, aby sie do niej odniesc drugi raz z poprzednim wynikiem
+                       $last = A
+                        - najprosciej przez pliki oszukujac silnik xsl
+                        - tozsamowsci $ID_Way $distanceGr
+                        - do edge_paths_with_PE_controll_temp, read z edge_paths_with_PE_controll_temp.alias
+                    -->
+                        <xsl:variable name="cache_file_name" select="concat($edge_paths_with_PE_controll_temp,'/odpalam_liczenie_or_nie_',$ID_Way,'_',$distanceGr,'.xml')"/>
+                        <xsl:variable name="PrevdistanceGr" select="number($distanceGr) - 1"/>
+                        <xsl:variable name="cache_file_name_previous" select="concat( $edge_paths_with_PE_controll_temp.alias,'/odpalam_liczenie_or_nie_',$ID_Way,'_',$PrevdistanceGr,'.xml')"/>
+                        <xsl:variable name="poprzednie_odpalam_liczenie_or_nie">
+                            <xsl:if test="$PrevdistanceGr &gt; 0 ">
+                                <xsl:copy-of select="doc($cache_file_name_previous)"/>
+                            </xsl:if>
+                        </xsl:variable>
+                        <!--<poprzednie_odpalam_liczenie_or_nie>
+                            <xsl:attribute name="cache_file_name_previous" select="$cache_file_name_previous"/>
+                            <xsl:copy-of select="$poprzednie_odpalam_liczenie_or_nie/poprzednie_odpalam_liczenie_or_nie"/>
+                        </poprzednie_odpalam_liczenie_or_nie>-->
                         
-                        <xsl:choose>
-                            <xsl:when test="count($candidates/bp:Path_Point) &lt; 10  and count($candidates/bp:Path_Point)&gt;1">
-                                <xsl:variable name="max_bit">
-                                    <xsl:for-each select="1 to count($candidates/bp:Path_Point)"><xsl:value-of select="1"/></xsl:for-each>
-                                </xsl:variable>
-                                <odpalam_liczenie>
-                                    <xsl:call-template name="calculate_optimum">
-                                        <xsl:with-param name="candidates" select="$candidates"/>
-                                        <xsl:with-param name="elements_cnt" select="count($candidates/bp:Path_Point)"/>
-                                        <xsl:with-param name="max_bit" select="$max_bit"/>
-                                    </xsl:call-template>
-                                </odpalam_liczenie>
-                            </xsl:when>
-                            <xsl:otherwise>
-                                <xsl:copy-of select="$candidates"></xsl:copy-of>
-                            </xsl:otherwise>
-                        </xsl:choose>
+                        <xsl:variable name="odpalam_liczenie_or_nie">
+                            <xsl:choose>
+                                <xsl:when test="count($candidates/bp:Path_Point) &lt; 10  and count($candidates/bp:Path_Point)&gt;1">
+                                    <xsl:variable name="max_bit">
+                                        <xsl:for-each select="1 to count($candidates/bp:Path_Point)"><xsl:value-of select="1"/></xsl:for-each>
+                                    </xsl:variable>
+                                    <odpalam_liczenie>
+                                        <!-- todo dolozyc poprzedni wezel dodany aby mogl od niego zawsze liczyc -->
+                                        <xsl:call-template name="calculate_optimum">
+                                            <xsl:with-param name="candidates" select="$candidates"/>
+                                            <xsl:with-param name="elements_cnt" select="count($candidates/bp:Path_Point)"/>
+                                            <xsl:with-param name="max_bit" select="$max_bit"/>
+                                            <xsl:with-param name="poprzednie_odpalam_liczenie_or_nie" select="$poprzednie_odpalam_liczenie_or_nie/poprzednie_odpalam_liczenie_or_nie"/>
+                                        </xsl:call-template>
+                                    </odpalam_liczenie>
+                                </xsl:when>
+                                <xsl:otherwise>
+                                    <xsl:for-each select="$candidates/bp:Path_Point">
+                                        <bp:Path_Point>
+                                            <xsl:copy-of select="@*"/>
+                                            <xsl:attribute name="bin_pos" select="1"/>
+                                        </bp:Path_Point>
+                                    </xsl:for-each>
+                                    <!--<xsl:copy-of select="$candidates"></xsl:copy-of>-->
+                                </xsl:otherwise>
+                            </xsl:choose>
+                        </xsl:variable>
+                        <xsl:copy-of select="$odpalam_liczenie_or_nie"/>
+                        <xsl:result-document href="{$cache_file_name}"> <!-- zapisanie do cache, aby odczytac w kolejnej petli-->
+                            <poprzednie_odpalam_liczenie_or_nie>
+                                <xsl:copy-of select="$odpalam_liczenie_or_nie/odpalam_liczenie/koniec_wariantow/bp:Path_Point"/>
+                                <xsl:copy-of select="$odpalam_liczenie_or_nie/bp:Path_Point"/>
+                            </poprzednie_odpalam_liczenie_or_nie>
+                        </xsl:result-document>
                     </PointMatrixGroup>
                 </xsl:for-each>
             </xsl:for-each>
@@ -282,6 +282,7 @@
         <xsl:param name="variant"  select="1"/>
         <xsl:param name="max_bit" required="yes"/>
         <xsl:param name="best_cost"/><xsl:param name="best_variant"/>
+        <xsl:param name="poprzednie_odpalam_liczenie_or_nie"/>
         <xsl:variable name="bit" select=" string-join(bp:decimalToBitFill($variant,$elements_cnt),'')"/>
         <xsl:variable name="cand_to_calc">
             <xsl:for-each select="$candidates/bp:Path_Point">
@@ -302,7 +303,10 @@
         <xsl:copy-of select="$cand_to_calc"/>
         </variant>
         <xsl:variable name="calc_cost_way">
-            <xsl:call-template name="calc_cost_way"><xsl:with-param name="cand_to_calc" select="$cand_to_calc"/></xsl:call-template>
+            <xsl:call-template name="calc_cost_way">
+                <xsl:with-param name="cand_to_calc" select="$cand_to_calc"/>
+                <xsl:with-param name="poprzednie_odpalam_liczenie_or_nie" select="$poprzednie_odpalam_liczenie_or_nie"/>
+            </xsl:call-template>
         </xsl:variable>
         <xsl:variable name="cost_sum">
             <costs>
@@ -336,7 +340,7 @@
             <xsl:when test="$bit = $max_bit">
                 <koniec_wariantow>
                     <xsl:attribute name="best_variant" select="$best_variant"/>
-                <xsl:for-each select="$candidates/bp:Path_Point">
+                    <xsl:for-each select="$candidates/bp:Path_Point">
                     <xsl:sort select="@distance"/>
                     <xsl:if test="substring($best_variant, position(),1)='1'"><!-- jak wystawiony w wariancie-->
                         <bp:Path_Point>
@@ -347,9 +351,9 @@
                             <xsl:copy-of select="bp:Path_Point"/>
                         </bp:Path_Point>
                     </xsl:if>
-                </xsl:for-each>
-                
-            </koniec_wariantow></xsl:when>
+                    </xsl:for-each>
+                 </koniec_wariantow>
+            </xsl:when>
             <xsl:otherwise>
                 <xsl:call-template name="calculate_optimum">
                     <xsl:with-param name="candidates" select="$candidates"/>
@@ -358,6 +362,7 @@
                     <xsl:with-param name="elements_cnt" select="$elements_cnt"/>
                     <xsl:with-param name="best_cost" select="$best/best/@best_cost"/>
                     <xsl:with-param name="best_variant" select="$best/best/@best_variant"/>
+                    <xsl:with-param name="poprzednie_odpalam_liczenie_or_nie" select="$poprzednie_odpalam_liczenie_or_nie"/>
                 </xsl:call-template>
             </xsl:otherwise>
         </xsl:choose>
@@ -366,8 +371,39 @@
     
     <xsl:template name="calc_cost_way"><!-- do wyliczenia ile wyjda kable w takiej konfiguracji -->
         <xsl:param name="cand_to_calc" required="yes"/>
-        <xsl:for-each select="$cand_to_calc/bp:Path_Point">
+        <xsl:param name="poprzednie_odpalam_liczenie_or_nie"/>
+        
+        <xsl:variable name="candidates_merged_with_poprzednie">
+            <xsl:for-each select="$poprzednie_odpalam_liczenie_or_nie/*">
+                <bp:Path_Point>
+                    <xsl:attribute name="poprzednia_grupa" select="true()"/>
+                    <xsl:copy-of select="@*"/>
+                </bp:Path_Point>
+            </xsl:for-each>
+            <xsl:for-each select="$cand_to_calc/bp:Path_Point">
+                <bp:Path_Point>
+                    <xsl:copy-of select="@*"/>
+                </bp:Path_Point>
+            </xsl:for-each>
+            <!--<xsl:copy-of select="$cand_to_calc/bp:Path_Point"/>-->
+        </xsl:variable>
+        
+        <!--<candidates_merged_with_poprzednie>
+            <cand_to_calc><xsl:copy-of select="$cand_to_calc"/></cand_to_calc>
+            <poprzedniee><xsl:copy-of select="$poprzednie_odpalam_liczenie_or_nie/poprzednie_odpalam_liczenie_or_nie"/></poprzedniee>
+            <merged><xsl:copy-of select="$candidates_merged_with_poprzednie"/></merged>
+        </candidates_merged_with_poprzednie>-->
+        
+        <xsl:for-each select="$candidates_merged_with_poprzednie/bp:Path_Point"> <!-- bylo cand_to_calc  -->
             <xsl:choose>
+                <xsl:when test="@poprzednia_grupa">
+                    <cost>
+                        <xsl:attribute name="Cable_Price" select="0"/>
+                        <xsl:attribute name="PE_Price" select="0"/>
+                        <xsl:attribute name="Price" select="0"/>
+                        <xsl:attribute name="debug" select="'ignore by last DistGroup'"/>
+                    </cost>
+                </xsl:when>
                 <xsl:when test="@bin_pos=0"><!-- szukamy gdzie ma najblizej i za ile -->
                     <xsl:variable name="way_up_id" select="max($cand_to_calc/bp:Path_Point[@bin_pos=1 and @id_path &lt;  current()/@id_path ]/number(@id_path))"/>
                     <xsl:variable name="way_up_len" >
@@ -435,6 +471,7 @@
                         <xsl:attribute name="Cable_Price" select="0"/>
                         <xsl:attribute name="PE_Price" select="$PE_Price"/>
                         <xsl:attribute name="Price" select="$PE_Price"/>
+                        <xsl:attribute name="mial_bin_pos" select="@bin_pos"/>
                     </cost>
                 </xsl:otherwise>
             </xsl:choose>
@@ -443,4 +480,14 @@
     </xsl:template>
     
     
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
 </xsl:stylesheet>

+ 78 - 0
SE/dev/php-cli/edge_paths_with_PE_controll_to_PE.xsl

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
+    
+    
+    exclude-result-prefixes="xs"
+    version="2.0">
+    
+    
+    <xsl:output indent="yes"/>
+    <xsl:strip-space elements="*"/>
+   
+    
+   
+    
+    
+    <xsl:template match="edge_paths_with_PE_controll">
+        
+             <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
+        
+    </xsl:template>
+    
+    
+    <xsl:template match="edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml">
+        <PE_candidates_dump>
+            <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
+        </PE_candidates_dump>
+    </xsl:template>
+    
+    <xsl:template match="Path" mode="edge_paths_with_PE.xml">
+        <LINESTRING>
+            <xsl:attribute name="ID_Way" select="@id"/>
+            <xsl:attribute name="Count"  select="@Count"/>
+            <xsl:attribute name="ID_Point_count" select="@Points_cnt"/>
+            <xsl:attribute name="distance"/>
+            <xsl:attribute name="dumb_frequency" select="''"/>
+            <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
+        </LINESTRING>
+    </xsl:template>
+    
+    <xsl:template match="PointMatrixGroupPE" mode="edge_paths_with_PE.xml">
+        
+        <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
+    </xsl:template>
+    
+    <xsl:template match="PointMatrixGroup" mode="edge_paths_with_PE.xml">
+        <!--<test_matrux><xsl:copy-of select="."></xsl:copy-of></test_matrux>-->
+        <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
+    </xsl:template>
+    
+    <xsl:template match="odpalam_liczenie" mode="edge_paths_with_PE.xml">
+        <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
+    </xsl:template>
+    <xsl:template match="koniec_wariantow" mode="edge_paths_with_PE.xml">
+        <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
+    </xsl:template>
+    
+    <xsl:template match="bp:Path_Point" mode="edge_paths_with_PE.xml">
+        <xsl:copy-of select="."/>
+    </xsl:template>
+    
+    <xsl:template match="variant" mode="edge_paths_with_PE.xml"/>
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+</xsl:stylesheet>