| 2127 | } |
| 2128 | |
| 2129 | void HEkkDual::updatePrimal(HVector* DSE_Vector) { |
| 2130 | // Update the primal values and any edge weights |
| 2131 | // |
| 2132 | // If reinversion is needed then skip this method |
| 2133 | if (rebuild_reason) return; |
| 2134 | std::vector<double>& edge_weight = ekk_instance_.dual_edge_weight_; |
| 2135 | if (edge_weight_mode == EdgeWeightMode::kDevex) { |
| 2136 | const double updated_edge_weight = edge_weight[row_out]; |
| 2137 | edge_weight[row_out] = computed_edge_weight; |
| 2138 | new_devex_framework = newDevexFramework(updated_edge_weight); |
| 2139 | } |
| 2140 | // DSE_Vector is either col_DSE = B^{-1}B^{-T}e_p (if using dual |
| 2141 | // steepest edge weights) or row_ep = B^{-T}e_p. |
| 2142 | // |
| 2143 | // Update - primal and weight |
| 2144 | dualRHS.updatePrimal(&col_BFRT, 1); |
| 2145 | dualRHS.updateInfeasList(&col_BFRT); |
| 2146 | double x_out = baseValue[row_out]; |
| 2147 | double l_out = baseLower[row_out]; |
| 2148 | double u_out = baseUpper[row_out]; |
| 2149 | theta_primal = (x_out - (delta_primal < 0 ? l_out : u_out)) / alpha_col; |
| 2150 | const bool ok_update_primal = dualRHS.updatePrimal(&col_aq, theta_primal); |
| 2151 | if (!ok_update_primal) { |
| 2152 | rebuild_reason = kRebuildReasonExcessivePrimalValue; |
| 2153 | return; |
| 2154 | } |
| 2155 | ekk_instance_.updateBadBasisChange(col_aq, theta_primal); |
| 2156 | if (edge_weight_mode == EdgeWeightMode::kSteepestEdge) { |
| 2157 | const double pivot_in_scaled_space = |
| 2158 | ekk_instance_.simplex_nla_.pivotInScaledSpace(&col_aq, variable_in, |
| 2159 | row_out); |
| 2160 | if (ekk_instance_.simplex_in_scaled_space_) |
| 2161 | assert(pivot_in_scaled_space == alpha_col); |
| 2162 | const double new_pivotal_edge_weight = |
| 2163 | edge_weight[row_out] / (pivot_in_scaled_space * pivot_in_scaled_space); |
| 2164 | const double Kai = -2 / pivot_in_scaled_space; |
| 2165 | ekk_instance_.updateDualSteepestEdgeWeights(row_out, variable_in, &col_aq, |
| 2166 | new_pivotal_edge_weight, Kai, |
| 2167 | DSE_Vector->array.data()); |
| 2168 | edge_weight[row_out] = new_pivotal_edge_weight; |
| 2169 | } else if (edge_weight_mode == EdgeWeightMode::kDevex) { |
| 2170 | // Pivotal row is for the current basis: weights are required for |
| 2171 | // the next basis so have to divide the current (exact) weight by |
| 2172 | // the pivotal value |
| 2173 | double new_pivotal_edge_weight = |
| 2174 | edge_weight[row_out] / (alpha_col * alpha_col); |
| 2175 | new_pivotal_edge_weight = max(1.0, new_pivotal_edge_weight); |
| 2176 | // nw_wt is max(use_edge_weight_[iRow], NewExactWeight*columnArray[iRow]^2); |
| 2177 | // |
| 2178 | // But NewExactWeight is new_pivotal_edge_weight = max(1.0, |
| 2179 | // edge_weight[row_out] / (alpha * alpha)) |
| 2180 | // |
| 2181 | // so nw_wt = max(use_edge_weight_[iRow], |
| 2182 | // new_pivotal_edge_weight*columnArray[iRow]^2); |
| 2183 | // |
| 2184 | // Update rest of weights |
| 2185 | ekk_instance_.updateDualDevexWeights(&col_aq, new_pivotal_edge_weight); |
| 2186 | edge_weight[row_out] = new_pivotal_edge_weight; |
no test coverage detected