|
|
@@ -7,7 +7,7 @@
|
|
|
exclude-result-prefixes="xs"
|
|
|
version="2.0">
|
|
|
|
|
|
- <!--<xsl:import href="PE_wariant_bit_table.xsl"/>-->
|
|
|
+ <xsl:import href="PE_wariant_bit_table.xsl"/>
|
|
|
|
|
|
<xsl:output indent="yes"/>
|
|
|
<xsl:strip-space elements="*"/>
|
|
|
@@ -72,6 +72,13 @@
|
|
|
<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>
|
|
|
@@ -177,7 +184,10 @@
|
|
|
<xsl:attribute name="distanceEnd" select="max(current-group()/number(@distance))"/>
|
|
|
<!--<xsl:attribute name="GroupPos" select="position()"/>-->
|
|
|
<xsl:for-each select="current-group()">
|
|
|
- <xsl:copy-of select="."/>
|
|
|
+ <distance2>
|
|
|
+ <xsl:attribute name="PosMatrGroup" select="position()"/>
|
|
|
+ <xsl:copy-of select="@*"></xsl:copy-of>
|
|
|
+ </distance2>
|
|
|
</xsl:for-each>
|
|
|
</PointMatrixGroupPos>
|
|
|
</xsl:for-each-group>
|
|
|
@@ -202,25 +212,48 @@
|
|
|
<xsl:attribute name="distanceBeg" select="@distanceBeg"/>
|
|
|
<xsl:attribute name="distanceEnd" select="@distanceEnd"/>
|
|
|
<!-- ida kandydaci -->
|
|
|
- <xsl:for-each select="distance2[( position() <= $bit_max_Pos and @point_count >0 ) or ( position()=1 and $point_count_Pos > 0 ) ]"> <!-- 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="distanceGr" select="$distanceGr"/>
|
|
|
- <xsl:attribute name="pos" select="@pos"/>
|
|
|
- <xsl:attribute name="len" select="@len"/>
|
|
|
- <xsl:attribute name="distance" select="@distance"/>
|
|
|
- <xsl:attribute name="cost_dist" select="@cost_dist"/>
|
|
|
- <xsl:attribute name="id_path" select="@id_path"/>
|
|
|
- <xsl:attribute name="point_count" select="@point_count"/>
|
|
|
-
|
|
|
- <xsl:attribute name="X" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@id_path = current()/@id_path]/@X"/>
|
|
|
- <xsl:attribute name="Y" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@id_path = current()/@id_path]/@Y"/>
|
|
|
- </bp:Path_Point>
|
|
|
- </xsl:for-each>
|
|
|
+ <xsl:variable name="candidates">
|
|
|
+ <xsl:for-each select="distance2[( position() <= $bit_max_Pos and @point_count >0 ) or ( position()=1 and $point_count_Pos > 0 ) ]"> <!-- 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()"/>
|
|
|
+ <xsl:attribute name="PosMatrGroup" select="@PosMatrGroup"/>
|
|
|
+ <xsl:attribute name="distanceGr" select="$distanceGr"/>
|
|
|
+ <xsl:attribute name="pos" select="@pos"/>
|
|
|
+ <xsl:attribute name="len" select="@len"/>
|
|
|
+ <xsl:attribute name="distance" select="@distance"/>
|
|
|
+ <xsl:attribute name="cost_dist" select="@cost_dist"/>
|
|
|
+ <xsl:attribute name="id_path" select="@id_path"/>
|
|
|
+ <xsl:attribute name="point_count" select="@point_count"/>
|
|
|
+
|
|
|
+ <xsl:attribute name="X" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@id_path = current()/@id_path]/@X"/>
|
|
|
+ <xsl:attribute name="Y" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@id_path = current()/@id_path]/@Y"/>
|
|
|
+ </bp:Path_Point>
|
|
|
+ </xsl:for-each>
|
|
|
+ </xsl:variable>
|
|
|
+
|
|
|
+ <xsl:choose>
|
|
|
+ <xsl:when test="count($candidates/bp:Path_Point) < 9 and count($candidates/bp:Path_Point)>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>
|
|
|
</PointMatrixGroup>
|
|
|
</xsl:for-each>
|
|
|
</xsl:for-each>
|
|
|
</PointMatrixGroupPE>
|
|
|
+
|
|
|
<!--<PointMatrix>
|
|
|
<xsl:attribute name="bit_max" select="$bit_max"/>
|
|
|
<xsl:attribute name="elements_cnt" select="$elements_cnt"/>
|
|
|
@@ -236,4 +269,141 @@
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
|
+
|
|
|
+ <xsl:template name="calculate_optimum">
|
|
|
+ <xsl:param name="candidates" required="yes"/>
|
|
|
+ <xsl:param name="elements_cnt" required="yes"/>
|
|
|
+ <xsl:param name="variant" select="1"/>
|
|
|
+ <xsl:param name="max_bit" required="yes"/>
|
|
|
+ <xsl:param name="best_cost"/><xsl:param name="best_variant"/>
|
|
|
+ <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">
|
|
|
+ <xsl:sort select="@distance"/>
|
|
|
+ <bp:Path_Point>
|
|
|
+ <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>
|
|
|
+ </bp:Path_Point>
|
|
|
+ </xsl:for-each>
|
|
|
+ </xsl:variable>
|
|
|
+ <!-- debug -->
|
|
|
+ <!--<variant><xsl:attribute name="variant" select="$variant"/>
|
|
|
+ <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:variable>
|
|
|
+ <!--<xsl:copy-of select="$calc_cost_way"/>-->
|
|
|
+ <xsl:variable name="best">
|
|
|
+ <xsl:variable name="cur_Price" select="sum($calc_cost_way/cost/number(@Price))"/>
|
|
|
+ <xsl:choose>
|
|
|
+ <xsl:when test="number($cur_Price) < number($best_cost) or not($best_cost) ">
|
|
|
+ <best>
|
|
|
+ <xsl:attribute name="best_cost" select="$cur_Price"/>
|
|
|
+ <xsl:attribute name="best_variant" select="$bit"/>
|
|
|
+ </best>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:otherwise>
|
|
|
+ <best>
|
|
|
+ <xsl:attribute name="best_cost" select="$best_cost"/>
|
|
|
+ <xsl:attribute name="best_variant" select="$best_variant"/>
|
|
|
+ </best>
|
|
|
+ </xsl:otherwise>
|
|
|
+ </xsl:choose>
|
|
|
+ </xsl:variable>
|
|
|
+ <!--<xsl:copy-of select="$best"/>-->
|
|
|
+
|
|
|
+ <xsl:choose>
|
|
|
+ <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:sort select="@distance"/>
|
|
|
+ <xsl:if test="substring($best_variant, position(),1)='1'"><!-- jak wystawiony w wariancie-->
|
|
|
+ <bp:Path_Point>
|
|
|
+ <xsl:attribute name="bit" select="$best_variant"/>
|
|
|
+ <xsl:attribute name="bin_pos" select="substring($best_variant, position(),1)"/>
|
|
|
+ <xsl:copy-of select="@*"/>
|
|
|
+ <xsl:attribute name="Price" select="$best_cost"/>
|
|
|
+ <xsl:copy-of select="bp:Path_Point"/>
|
|
|
+ </bp:Path_Point>
|
|
|
+ </xsl:if>
|
|
|
+ </xsl:for-each>
|
|
|
+
|
|
|
+ </koniec_wariantow></xsl:when>
|
|
|
+ <xsl:otherwise>
|
|
|
+ <xsl:call-template name="calculate_optimum">
|
|
|
+ <xsl:with-param name="candidates" select="$candidates"/>
|
|
|
+ <xsl:with-param name="max_bit" select="$max_bit"/>
|
|
|
+ <xsl:with-param name="variant" select="$variant + 1"/>
|
|
|
+ <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:call-template>
|
|
|
+ </xsl:otherwise>
|
|
|
+ </xsl:choose>
|
|
|
+
|
|
|
+ </xsl:template>
|
|
|
+
|
|
|
+ <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:choose>
|
|
|
+ <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 < current()/@id_path ]/number(@id_path))"/>
|
|
|
+ <xsl:variable name="way_up_len" >
|
|
|
+ <xsl:choose>
|
|
|
+ <xsl:when test="$way_up_id">
|
|
|
+ <xsl:value-of select="number( current()/@distance) - number($cand_to_calc/bp:Path_Point[@id_path=$way_up_id]/@distance)"/></xsl:when>
|
|
|
+ <xsl:otherwise><xsl:value-of select="-1"/></xsl:otherwise>
|
|
|
+ </xsl:choose>
|
|
|
+ </xsl:variable>
|
|
|
+ <xsl:variable name="way_dn_id" select="max($cand_to_calc/bp:Path_Point[@bin_pos=1 and @id_path > current()/@id_path ]/number(@id_path)) " />
|
|
|
+ <xsl:variable name="way_dn_len">
|
|
|
+ <xsl:choose>
|
|
|
+ <xsl:when test="$way_dn_id">
|
|
|
+ <xsl:value-of select=" number($cand_to_calc/bp:Path_Point[@id_path=$way_dn_id]/@distance ) - current()/@distance"/>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:otherwise><xsl:value-of select="-1"/></xsl:otherwise>
|
|
|
+ </xsl:choose>
|
|
|
+ </xsl:variable>
|
|
|
+ <xsl:choose><!-- czy w gore czy w dol -->
|
|
|
+ <xsl:when test=" number($way_up_len) >= number($way_dn_len) and number($way_dn_len) > 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:attribute name="PE_Price" select="0"/>
|
|
|
+ <xsl:attribute name="Price" select="$Cable_Price"/>
|
|
|
+ <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:attribute name="PE_Price" select="0"/>
|
|
|
+ <xsl:attribute name="Price" select="$Cable_Price"/>
|
|
|
+ <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"/>
|
|
|
+ </cost>
|
|
|
+ </xsl:otherwise>
|
|
|
+ </xsl:choose>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:otherwise>
|
|
|
+ <cost>
|
|
|
+ <xsl:attribute name="Cable_Price" select="0"/>
|
|
|
+ <xsl:attribute name="PE_Price" select="$PE_Price"/>
|
|
|
+ <xsl:attribute name="Price" select="$PE_Price"/>
|
|
|
+ </cost>
|
|
|
+ </xsl:otherwise>
|
|
|
+ </xsl:choose>
|
|
|
+ </xsl:for-each>
|
|
|
+
|
|
|
+ </xsl:template>
|
|
|
+
|
|
|
+
|
|
|
</xsl:stylesheet>
|