a.binder 9 lat temu
rodzic
commit
d02df7e0f9
1 zmienionych plików z 46 dodań i 15 usunięć
  1. 46 15
      SE/dev/php-cli/edge_paths_with_PE_controll.xsl

+ 46 - 15
SE/dev/php-cli/edge_paths_with_PE_controll.xsl

@@ -13,7 +13,7 @@
     <xsl:strip-space elements="*"/>
     
     <xsl:param name="PE_Price" select="1500"/>
-    <xsl:param name="Cable_Price" select="10"/>
+    <xsl:param name="Cable_Price" select="40"/>
     
     <xsl:param name="edge_paths_with_PE.xml"/>
     
@@ -164,12 +164,12 @@
             <xsl:copy-of select="$EconomicDistanceCut2"/>
             
             <xsl:variable name="elements_cnt" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@point_count &gt; 0])"/><!-- liczba wezlow potencjalnych licbza PE-->
-            <xsl:variable name="bit_max" select="round($len  div  ( $PE_Price div $Cable_Price ) + count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@cost_dist &gt; $PE_Price]) )"/><!-- max licbza PE-->
+            <xsl:variable name="bit_max" select="round($len  div  ( $PE_Price div $Cable_Price ) + count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@cost_dist &gt; $PE_Price]) +10 )"/><!-- max licbza PE-->
             
             <!-- pogrupujemy elementy co 50 metrow -->
             <xsl:variable name="PointMatrixGroup">
                 <PointMatrixGroup>
-                    <xsl:for-each-group select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2" group-by="round( @distance div ( $PE_Price div $Cable_Price + 50 ))">
+                    <xsl:for-each-group select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2" group-by="round( @distance div ( $PE_Price div $Cable_Price + 100 ))">
                         <PointMatrixGroupPos>
                             <xsl:variable name="elements_cnt_Pos" select="count(current-group()[@point_count &gt; 0])"/>
                             <xsl:variable name="bit_max_Pos" select="round(sum( current-group()/@disttopkt )  div  ( $PE_Price div 20 ) )"/>
@@ -213,7 +213,7 @@
                         <xsl:attribute name="distanceEnd" select="@distanceEnd"/>
                 <!-- ida kandydaci -->
                         <xsl:variable name="candidates">
-                            <xsl:for-each select="distance2[( position() &lt;= $bit_max_Pos and @point_count &gt;0 ) or (  position()=1 and $point_count_Pos &gt; 0 ) ]"> <!-- jak jest maly wspolczynnik to chociaz jeden punkt jak sa punkty jakies w tej grupie -->
+                            <xsl:for-each select="distance2[( position() &lt;= $bit_max_Pos and @point_count &gt;0 ) or (  position()=1 and $point_count_Pos &gt; 0 )  or position()= last()]"> <!-- jak jest maly wspolczynnik to chociaz jeden punkt jak sa punkty jakies w tej grupie -->
                                     <xsl:sort select="@cost_dist" order="descending"/>
                                     <bp:Path_Point>
                                         <xsl:attribute name="DebugPosPoint" select="position()"/>
@@ -233,7 +233,7 @@
                         </xsl:variable>
                         
                         <xsl:choose>
-                            <xsl:when test="count($candidates/bp:Path_Point) &lt; 9  and count($candidates/bp:Path_Point)&gt;1">
+                            <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>
@@ -281,7 +281,7 @@
             <xsl:for-each select="$candidates/bp:Path_Point">
                 <xsl:sort select="@distance"/>
                 <bp:Path_Point>
-                    <xsl:attribute name="bit" select="$bit"/>
+                    <!--<xsl:attribute name="bit" select="$bit"/>-->
                     <xsl:attribute name="bin_pos"  select="substring($bit, position(),1)"/>
                     <xsl:copy-of select="@*"/>
                     <xsl:copy-of select="bp:Path_Point"></xsl:copy-of>
@@ -289,15 +289,26 @@
             </xsl:for-each>
         </xsl:variable>
         <!-- debug -->
-        <!--<variant><xsl:attribute name="variant" select="$variant"/>
+        <variant><xsl:attribute name="variant" select="$variant"/>
+            <xsl:attribute name="cur_bit" select="$bit"/>
+            <xsl:attribute name="best_cost" select="$best_cost"/>
+            <xsl:attribute name="best_variant" select="$best_variant"/>
         <xsl:copy-of select="$cand_to_calc"/>
-        </variant>-->
+        </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:variable>
-        <!--<xsl:copy-of select="$calc_cost_way"/>-->
+        <xsl:variable name="cost_sum">
+            <costs>
+                <xsl:attribute name="Cable_Price" select="sum($calc_cost_way/cost/@Cable_Price)" />
+                <xsl:attribute name="PE_Price" select="sum($calc_cost_way/cost/@PE_Price)"/>
+                <xsl:attribute name="Price" select="sum($calc_cost_way/cost/@Price)"/>
+                <xsl:copy-of select="$calc_cost_way"/>    
+            </costs>
+        </xsl:variable>
+        <xsl:copy-of select="$cost_sum"></xsl:copy-of>
         <xsl:variable name="best">
-            <xsl:variable name="cur_Price" select="sum($calc_cost_way/cost/number(@Price))"/>
+            <xsl:variable name="cur_Price" select="$cost_sum/costs/@Price"/>
             <xsl:choose>
                 <xsl:when test="number($cur_Price) &lt; number($best_cost) or not($best_cost) ">
                     <best>
@@ -372,20 +383,40 @@
                     <xsl:choose><!-- czy w gore czy w dol -->
                         <xsl:when test=" number($way_up_len)  &gt;= number($way_dn_len) and  number($way_dn_len) &gt; 0 or $way_up_len=-1"> <!--and not($way_dn_len='NaN') -->
                             <cost>
-                                <xsl:attribute name="Cable_Price" select="$Cable_Price * $way_dn_len "/> <!-- todo @point_count -->
+                                <xsl:variable name="Cable_Price_sum">
+                                    <xsl:choose>
+                                        <xsl:when test="number(@point_count) &gt; 0 ">
+                                            <xsl:value-of select="$Cable_Price * $way_dn_len * number(@point_count) "/>
+                                        </xsl:when>
+                                        <xsl:otherwise>
+                                            <xsl:value-of select="$Cable_Price * $way_dn_len "/> <!-- todo @point_count -->
+                                        </xsl:otherwise>
+                                    </xsl:choose>
+                                </xsl:variable>
+                                 <!-- todo @point_count -->
                                 <xsl:attribute name="PE_Price" select="0"/>
-                                <xsl:attribute name="Price" select="$Cable_Price"/>
+                                <xsl:attribute name="Cable_Price" select="$Cable_Price_sum"/>
+                                <xsl:attribute name="Price" select="$Cable_Price_sum"/>
                                 <xsl:attribute name="choosed" select="'down'"/>
                                 <xsl:attribute name="way_up_id" select="$way_up_id"/><xsl:attribute name="way_up_len" select="$way_up_len"/>
                                 <xsl:attribute name="way_dn_id" select="$way_dn_id"/><xsl:attribute name="way_dn_len" select="$way_dn_len"/>
                             </cost>
                         </xsl:when>
-                        
                         <xsl:otherwise>
                             <cost>
-                                <xsl:attribute name="Cable_Price" select="$Cable_Price * $way_up_len "/> <!-- todo @point_count -->
+                                <xsl:variable name="Cable_Price_sum">
+                                    <xsl:choose>
+                                        <xsl:when test="number(@point_count) &gt; 0 ">
+                                            <xsl:value-of select="$Cable_Price * $way_up_len * number(@point_count) "/>
+                                        </xsl:when>
+                                        <xsl:otherwise>
+                                            <xsl:value-of select="$Cable_Price * $way_up_len "/> <!-- todo @point_count -->
+                                        </xsl:otherwise>
+                                    </xsl:choose>
+                                </xsl:variable>
+                                <xsl:attribute name="Cable_Price" select="$Cable_Price_sum"/> <!-- todo @point_count -->
                                 <xsl:attribute name="PE_Price" select="0"/>
-                                <xsl:attribute name="Price" select="$Cable_Price"/>
+                                <xsl:attribute name="Price" select="$Cable_Price_sum"/>
                                 <xsl:attribute name="choosed" select="'up'"/>
                                 <xsl:attribute name="way_up_id" select="$way_up_id"/><xsl:attribute name="way_up_len" select="$way_up_len"/>
                                 <xsl:attribute name="way_dn_id" select="$way_dn_id"/><xsl:attribute name="way_dn_len" select="$way_dn_len"/>