| 25 | }; |
| 26 | |
| 27 | struct TModelSplit { |
| 28 | ESplitType Type; |
| 29 | TFloatSplit FloatFeature; |
| 30 | TModelCtrSplit OnlineCtr; |
| 31 | TOneHotSplit OneHotFeature; |
| 32 | TEstimatedFeatureSplit EstimatedFeature; |
| 33 | |
| 34 | public: |
| 35 | TModelSplit() = default; |
| 36 | |
| 37 | explicit TModelSplit(const TFloatSplit& floatFeature) |
| 38 | : Type(ESplitType::FloatFeature) |
| 39 | , FloatFeature(floatFeature) |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | explicit TModelSplit(const TOneHotSplit& oheFeature) |
| 44 | : Type(ESplitType::OneHotFeature) |
| 45 | , OneHotFeature(oheFeature) |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | explicit TModelSplit(const TModelCtrSplit& onlineCtr) |
| 50 | : Type(ESplitType::OnlineCtr) |
| 51 | , OnlineCtr(onlineCtr) |
| 52 | { |
| 53 | } |
| 54 | |
| 55 | explicit TModelSplit(const TEstimatedFeatureSplit& estimatedFeature) |
| 56 | : Type(ESplitType::EstimatedFeature) |
| 57 | , EstimatedFeature(estimatedFeature) |
| 58 | { |
| 59 | } |
| 60 | |
| 61 | bool operator==(const TModelSplit& other) const { |
| 62 | return Type == other.Type && |
| 63 | ((Type == ESplitType::FloatFeature && FloatFeature == other.FloatFeature) || |
| 64 | (Type == ESplitType::OnlineCtr && OnlineCtr == other.OnlineCtr) || |
| 65 | (Type == ESplitType::OneHotFeature && OneHotFeature == other.OneHotFeature) || |
| 66 | (Type == ESplitType::EstimatedFeature && EstimatedFeature == other.EstimatedFeature)); |
| 67 | } |
| 68 | |
| 69 | bool operator<(const TModelSplit& other) const { |
| 70 | if (Type < other.Type) { |
| 71 | return true; |
| 72 | } |
| 73 | if (Type > other.Type) { |
| 74 | return false; |
| 75 | } |
| 76 | if (Type == ESplitType::FloatFeature) { |
| 77 | return FloatFeature < other.FloatFeature; |
| 78 | } else if (Type == ESplitType::OnlineCtr) { |
| 79 | return OnlineCtr < other.OnlineCtr; |
| 80 | } else if (Type == ESplitType::OneHotFeature) { |
| 81 | return OneHotFeature < other.OneHotFeature; |
| 82 | } else { |
| 83 | Y_ASSERT(Type == ESplitType::EstimatedFeature); |
| 84 | return EstimatedFeature < other.EstimatedFeature; |
no outgoing calls