Linux平台下编译及冗余文件删除

This commit is contained in:
2025-08-25 13:33:35 +08:00
parent a78045b4d3
commit 9f029ef7e4
4 changed files with 25 additions and 104 deletions

View File

@@ -6,6 +6,9 @@
#include <algorithm>
#include <stack>
#include <cassert>
#include <cstring>
#include <cfloat>
#include <math.h>
using namespace sv;
using std::make_pair;
@@ -64,14 +67,14 @@ LinSolver& sv::LinSolver::operator=(const LinSolver& solver)
if (this == &solver) {
return *this;
}
delete[] vars; // <20>ͷ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD>ڴ<EFBFBD>
delete[] vars; // <20>ͷ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD>ڴ<EFBFBD>
vars = nullptr;
cn = solver.cn;
if (cn > 0) {
vars = new Var[cn];
for (int i = 0; i < cn; i++) {
vars[i] = solver.vars[i]; // <20><EFBFBD><EEBFBD>
vars[i] = solver.vars[i]; // <20><EFBFBD><EEBFBD>
}
}
table = solver.table;
@@ -101,7 +104,7 @@ Var* LinSolver::addVars(int num, VarType type)
const Var& sv::LinSolver::getVar(int idx)
{
assert(idx >= 0 && idx < cn); // <20><><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
assert(idx >= 0 && idx < cn); // <20><><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD>
return vars[idx];
}
@@ -203,7 +206,11 @@ rtn Model::optimize()
std::stack<Node> list_;
Node root_node(solver, 0, solver.obj_);
Node root_node;
root_node.solver = solver;
root_node.lower_bound = 0;
root_node.upper_bound = solver.obj_;
Node incumbent_node = root_node;
list_.push(root_node);
@@ -325,7 +332,7 @@ rtn LinSolver::feasible_solution()
basic.push_back(cn - bn + i);
}
// === <20>жϳ<D0B6>ʼ<EFBFBD><CABC><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>н<EFBFBD> ===
// === <20>жϳ<D0B6>ʼ<EFBFBD><CABC><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>н<EFBFBD> ===
bool initial_feasible = true;
for (int row = 1; row < bn; row++) {
if (ope_table.at(row).front() < 0) {
@@ -334,7 +341,7 @@ rtn LinSolver::feasible_solution()
}
}
// === <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>н<EFBFBD> ===
// === <20><><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>н<EFBFBD> ===
if (!initial_feasible) {
vector<double> coeff = ope_table.front();
ope_table.front() = vector<double>(cn, .0);
@@ -386,10 +393,10 @@ rtn LinSolver::feasible_solution()
rtn LinSolver::_pivot(pair<size_t, size_t>& p)
{
p = make_pair(0, 0);
double cmin = INT_MAX;
double cmin = DBL_MAX;
vector<double> coef = ope_table.front();
// === <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сֵ ===
// === <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сֵ ===
for (size_t col = 1; col < coef.size(); col++) {
if (cmin > coef.at(col) && find(basic.begin(), basic.end(), col) == basic.end()) {
cmin = coef.at(col);
@@ -399,7 +406,7 @@ rtn LinSolver::_pivot(pair<size_t, size_t>& p)
if (cmin >= 0) {
return OPTIMAL;
}
double bmin = INT_MAX;
double bmin = DBL_MAX;
for (size_t row = 1; row < bn; row++) {
double tmp = ope_table.at(row).front() / ope_table.at(row).at(p.second);
if (ope_table.at(row).at(p.second) > 0 && bmin > tmp) {
@@ -408,7 +415,7 @@ rtn LinSolver::_pivot(pair<size_t, size_t>& p)
}
}
if (abs(bmin - INT_MAX) < 1e-10) {
if (abs(bmin - DBL_MAX) < 1e-10) {
return UNBOUNDED;
}
@@ -426,13 +433,13 @@ void LinSolver::_gaussian(pair<size_t, size_t> p)
{
size_t x = p.first, y = p.second;
// === <20><><EFBFBD>й<EFBFBD>һ<EFBFBD><D2BB> ===
// === <20><><EFBFBD>й<EFBFBD>һ<EFBFBD><D2BB> ===
double norm = ope_table.at(x).at(y);
for (size_t col = 0; col < ope_table.at(x).size(); col++) {
ope_table.at(x).at(col) /= norm;
}
// === <20><><EFBFBD><EFBFBD><EFBFBD>б任 ===
// === <20><><EFBFBD><EFBFBD><EFBFBD>б任 ===
for (size_t row = 0; row < bn; row++) {
if (row == x) {
continue;
@@ -444,6 +451,6 @@ void LinSolver::_gaussian(pair<size_t, size_t> p)
}
}
}
basic.at(x - 1) = y; // <20><>Ԫ
basic.at(x - 1) = y; // <20><>Ԫ
}