using System.Collections.Generic;
using System.Threading.Tasks;
public static void Main()
double baseAvgPrice = 100;
ScoreItem left = new ScoreItem(baseAvgPrice, avgPrice:100, stddev:0, numFound:10);
ScoreItem right = new ScoreItem(baseAvgPrice, avgPrice:170, stddev:100, numFound:100);
Console.WriteLine(right > left);
public ScoreItem(double directSearchBaseAvgPrice, double avgPrice, double stddev, long numFound)
this._directSearchBaseAvgPrice = directSearchBaseAvgPrice;
this._avgPrice = avgPrice;
this._numFound = numFound;
public static bool operator >(ScoreItem lhs, ScoreItem rhs)
if (平均與標準差都在合理範圍(lhs, lhs._directSearchBaseAvgPrice) && 平均與標準差都在合理範圍(rhs, rhs._directSearchBaseAvgPrice))
if (lhs._numFound >= rhs._numFound)
public static bool operator <(ScoreItem lhs, ScoreItem rhs)
private static bool 平均與標準差都在合理範圍(ScoreItem aThis, double directSearchBaseAvgPrice)
PriceRangeHelper.InitPriceRangeDefaultArray();
PriceRage foundPriceRange = PriceRangeHelper.GetPriceRange((int)aThis._directSearchBaseAvgPrice);
return (aThis._stddev / directSearchBaseAvgPrice <= 1) &&
(aThis._avgPrice <= (aThis._directSearchBaseAvgPrice * foundPriceRange.benefitSpace) && aThis._avgPrice >= (aThis._directSearchBaseAvgPrice * 0.5));
private double _directSearchBaseAvgPrice;
private double _avgPrice;
public class PriceRangeHelper
public static void InitPriceRangeDefaultArray()
PriceRageDefaultArray[0].benefitSpace = 1.2; PriceRageDefaultArray[0].bottom = 100;
PriceRageDefaultArray[1].benefitSpace = 1.25; PriceRageDefaultArray[1].bottom = 500;
PriceRageDefaultArray[2].benefitSpace = 1.3; PriceRageDefaultArray[2].bottom = 1000;
PriceRageDefaultArray[3].benefitSpace = 1.35; PriceRageDefaultArray[3].bottom = 2000;
PriceRageDefaultArray[4].benefitSpace = 1.4; PriceRageDefaultArray[4].bottom = 5000;
PriceRageDefaultArray[5].benefitSpace = 1.45; PriceRageDefaultArray[5].bottom = 10000;
PriceRageDefaultArray[6].benefitSpace = 1.5; PriceRageDefaultArray[6].bottom = 50000;
PriceRageDefaultArray[7].benefitSpace = 2; PriceRageDefaultArray[7].bottom = 9999999;
public static PriceRage GetPriceRange(int price)
PriceRage foundPriceRange = PriceRageDefaultArray[0];
for(int i = 0 ; i < 8 ; i++)
var pr = PriceRageDefaultArray[i];
Console.WriteLine("bs:" + foundPriceRange.benefitSpace);
private static bool isInitialized = false;
private static PriceRage[] PriceRageDefaultArray = new PriceRage[8];
public double benefitSpace;