本文整理汇总了C++中Customer::getX方法的典型用法代码示例。如果您正苦于以下问题:C++ Customer::getX方法的具体用法?C++ Customer::getX怎么用?C++ Customer::getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::getX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDistanceIJ
double CVRP::getDistanceIJ(Customer c1, Customer c2) {
double dx = 0.0, dy = 0.0, dr = 0.0;
int a = 0, b = 0;
a = c1.getX() - c2.getX();
b = c1.getY() - c2.getY();
dx = pow(a, 2);
dy = pow(b, 2);
dr = sqrt(dx + dy);
return dr;
}
示例2: compareCustomers
bool CVRP::compareCustomers(Customer c1, Customer c2) {
if ((c1.getX() == c2.getX()) && (c1.getY() == c2.getY())) {
return true;
}
return false;
}
示例3: init
void CVRP::init(VRP V) {
cout.setf(ios::fixed | ios::showpoint);
cout.precision(2);
std::cout.imbue(
std::locale(std::cout.getloc(), new punct_facet<char, ','>));
bool init1 = false;
if (init1) {
setNroCustomers(V.getBusStops().size() + 1);
Customer depot(V.getCoorSchool().getX(), V.getCoorSchool().getY(),
V.getCoorSchool().getCapacity());
std::vector<Stop> a;
a.insert(a.begin() + 0, V.getCoorSchool());
std::vector<Stop> b = V.getBusStops();
//Set AllCustomer but not depot
std::vector<Customer> allCustNotDepot;
for (size_t i = 0; i < V.getBusStops().size(); i++) {
Stop stop = V.getBusStops().at(i);
Customer customer(stop.getX(), stop.getY(), stop.getCapacity());
allCustNotDepot.insert(allCustNotDepot.begin() + i, customer);
}
setAllCustNoDepot(allCustNotDepot);
a.insert(a.end(), b.begin(), b.end());
std::vector<Customer> allCustomers;
for (size_t i = 0; i < a.size(); i++) {
Stop stop = a.at(i);
Customer customer(stop.getX(), stop.getY(), stop.getCapacity());
allCustomers.insert(allCustomers.begin() + i, customer);
}
for (size_t i = 0; i < allCustomers.size(); i++) {
Customer customer = allCustomers.at(i);
cout << "(" << customer.getX() << ", " << customer.getY() << ", "
<< customer.getDemand() << ")" << endl;
}
setDepot(depot);
setAllCustomers(allCustomers);
setK(V.getK());
setC(V.getCk());
setKmin(V.getKmin());
} else {
setNroCustomers(V.getBusAssigned().size() + 1);
Customer depot(V.getCoorSchool().getX(), V.getCoorSchool().getY(),
V.getCoorSchool().getCapacity());
std::vector<Stop> a;
a.insert(a.begin() + 0, V.getCoorSchool());
std::vector<Stop> b = V.getBusAssigned();
//Set AllCustomer but not depot
std::vector<Customer> allCustNotDepot;
for (size_t i = 0; i < V.getBusAssigned().size(); i++) {
Stop stop = V.getBusAssigned().at(i);
Customer customer(stop.getX(), stop.getY(), stop.getCapacity());
allCustNotDepot.insert(allCustNotDepot.begin() + i, customer);
}
setAllCustNoDepot(allCustNotDepot);
a.insert(a.end(), b.begin(), b.end());
std::vector<Customer> allCustomers;
for (size_t i = 0; i < a.size(); i++) {
Stop stop = a.at(i);
Customer customer(stop.getX(), stop.getY(), stop.getCapacity());
allCustomers.insert(allCustomers.begin() + i, customer);
}
cout << "List of customers! the first customert is the depot." << endl;
for (size_t i = 0; i < allCustomers.size(); i++) {
Customer customer = allCustomers.at(i);
cout << "(" << customer.getX() << ", " << customer.getY() << ", "
<< customer.getDemand() << ")" << endl;
}
setDepot(depot);
setAllCustomers(allCustomers);
setK(V.getK());
setC(V.getCk());
setKmin(V.getKmin());
}
//Validation of the numbers of enters to the depot
//Initialization of x
//Initialization of d
std::vector<Customer> allCustomers = getAllCustomers();
int nro_customers = getNroCustomers();
double** d_cvpr = new double*[nro_customers];
double** s_cvpr = new double*[nro_customers];
bool** x_cvpr = new bool*[nro_customers];
for (int i = 0; i < nro_customers; i++) {
d_cvpr[i] = new double[nro_customers];
x_cvpr[i] = new bool[nro_customers];
s_cvpr[i] = new double[nro_customers];
}
cout << "Save the distance in a d array of array" << endl;
for (int i = 0; i < nro_customers; i++) {
Customer customer = allCustomers.at(i);
cout << "(" << customer.getX() << ", " << customer.getY() << ")"
<< endl;
//.........这里部分代码省略.........