本文整理汇总了C#中IVRPProblemInstance.GetCoordinates方法的典型用法代码示例。如果您正苦于以下问题:C# IVRPProblemInstance.GetCoordinates方法的具体用法?C# IVRPProblemInstance.GetCoordinates怎么用?C# IVRPProblemInstance.GetCoordinates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVRPProblemInstance
的用法示例。
在下文中一共展示了IVRPProblemInstance.GetCoordinates方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateAngleToDepot
private static double CalculateAngleToDepot(IVRPProblemInstance instance, int city) {
double dx = instance.GetCoordinates(0)[0];
double dy = instance.GetCoordinates(0)[1];
double cx = instance.GetCoordinates(city)[0];
double cy = instance.GetCoordinates(city)[1];
double alpha = Math.Atan((cx - dx) / (dy - cy)) * (180.0 / Math.PI);
if (cx > dx && cy > dy)
alpha = (90.0 + alpha) + 90.0;
else if (cx < dx && cy > dy)
alpha = alpha + 180.0;
else if (cx < dx && cy < dy)
alpha = (90.0 + alpha) + 270.0;
return alpha;
}
示例2: CalculateCentroidDistance
private double CalculateCentroidDistance(Tour t1, Tour t2, IVRPProblemInstance instance) {
double xSum = 0;
double ySum = 0;
double c1X, c1Y, c2X, c2Y;
for (int i = 0; i < t1.Stops.Count; i++) {
xSum += instance.GetCoordinates(t1.Stops[i])[0];
ySum += instance.GetCoordinates(t1.Stops[i])[1];
}
c1X = xSum / t1.Stops.Count;
c1Y = ySum / t1.Stops.Count;
for (int i = 0; i < t2.Stops.Count; i++) {
xSum += instance.GetCoordinates(t2.Stops[i])[0];
ySum += instance.GetCoordinates(t2.Stops[i])[1];
}
c2X = xSum / t1.Stops.Count;
c2Y = ySum / t1.Stops.Count;
return Math.Sqrt(
(c1X - c2X) * (c1X - c2X) +
(c1Y - c2Y) * (c1Y - c2Y));
}