Package org.apache.sysds.hops.fedplanner

# Class FederatedPlanCostEstimator

java.lang.Object
org.apache.sysds.hops.fedplanner.FederatedPlanCostEstimator

public class FederatedPlanCostEstimator extends Object
Cost estimator for federated execution plans. Calculates computation, memory access, and network transfer costs for federated operations. Works in conjunction with FederatedMemoTable to evaluate different execution plan variants.

## Constructor Summary

Constructors
Constructor
Description
`FederatedPlanCostEstimator()`

## Method Summary

Modifier and Type
Method
Description
`static double`
`computeHopCost(FederatedMemoTable.HopCommon hopCommon)`
Computes the cost associated with a given Hop node.
`static void`
`getChildCosts(FederatedMemoTable.HopCommon hopCommon, FederatedMemoTable memoTable, List<Hop> inputHops, double[][] childCumulativeCost, double[] childForwardingCost, List<Hop> lOUTOnlyinputHops, List<Double> lOUTOnlychildCumulativeCost, List<Double> lOUTOnlychildForwardingCost, List<Hop> fOUTOnlyinputHops, List<Double> fOUTOnlychildCumulativeCost, List<Double> fOUTOnlychildForwardingCost)`
`static LinkedHashMap<FederatedMemoTable.FedPlan,Boolean>`
`resolveConflictFedPlan(FederatedMemoTable memoTable, LinkedHashMap<Long,List<FederatedMemoTable.FedPlan>> conflictFedPlanLinkedMap, double[] cumulativeAdditionalCost)`
Resolves conflicts in federated plans where different plans have different FederatedOutput types.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### FederatedPlanCostEstimator

public FederatedPlanCostEstimator()

## Method Details

### getChildCosts

public static void getChildCosts(FederatedMemoTable.HopCommon hopCommon, FederatedMemoTable memoTable, List<Hop> inputHops, double[][] childCumulativeCost, double[] childForwardingCost, List<Hop> lOUTOnlyinputHops, List<Double> lOUTOnlychildCumulativeCost, List<Double> lOUTOnlychildForwardingCost, List<Hop> fOUTOnlyinputHops, List<Double> fOUTOnlychildCumulativeCost, List<Double> fOUTOnlychildForwardingCost)

### computeHopCost

public static double computeHopCost(FederatedMemoTable.HopCommon hopCommon)
Computes the cost associated with a given Hop node. This method calculates both the self cost and the forwarding cost for the Hop, taking into account its type and the number of parent nodes.

Parameters:
  `hopCommon` - The HopCommon object containing the Hop and its properties.
Returns:
  The self cost of the Hop.

### resolveConflictFedPlan

public static LinkedHashMap<FederatedMemoTable.FedPlan,Boolean> resolveConflictFedPlan(FederatedMemoTable memoTable, LinkedHashMap<Long,List<FederatedMemoTable.FedPlan>> conflictFedPlanLinkedMap, double[] cumulativeAdditionalCost)
Resolves conflicts in federated plans where different plans have different FederatedOutput types. This function traverses the list of conflicting plans in reverse order to ensure that conflicts are resolved from the bottom-up, allowing for consistent federated output types across the plan. It calculates additional costs for each potential resolution and updates the cumulative additional cost.

Parameters:
  `memoTable` - The FederatedMemoTable containing all federated plan variants.
  `conflictFedPlanLinkedMap` - A map of plan IDs to lists of parent plans with conflicting federated outputs.
  `cumulativeAdditionalCost` - An array to store the cumulative additional cost incurred by resolving conflicts.
Returns:
  A LinkedHashMap of resolved federated plans, marked with a boolean indicating resolution status.