Package com.opengamma.engine.depgraph

Examples of com.opengamma.engine.depgraph.DependencyGraph


        Object gridStructure = null;
        if (!depGraphGrid.isInit()) {
          String calcConfigName = depGraphGrid.getParentCalcConfigName();
          ValueSpecification valueSpecification = depGraphGrid.getParentValueSpecification();
          DependencyGraphExplorer explorer = cycleReference.get().getCompiledViewDefinition().getDependencyGraphExplorer(calcConfigName);
          DependencyGraph subgraph = explorer.getSubgraphProducing(valueSpecification);
          if (subgraph == null) {
            s_logger.warn("No subgraph producing value specification {}", valueSpecification);
            continue;
          }
          if (depGraphGrid.init(subgraph, calcConfigName, valueSpecification)) {
View Full Code Here


      viewDef = (CompiledViewDefinitionWithGraphs) compiledViewDef;
    } else {
      viewDef = cycle.getCompiledViewDefinition();
    }
    DependencyGraphExplorer depGraphExplorer = viewDef.getDependencyGraphExplorer(calcConfigName);
    DependencyGraph depGraph = depGraphExplorer.getSubgraphProducing(rootSpec);
    AnalyticsNode node = createNode(rootSpec, depGraph, true);
    _structure = new DependencyGraphGridStructure(node, calcConfigName, requirement, _valueSpecs, _fnNames, targetResolver);
  }
View Full Code Here

      while (builders.hasNext()) {
        final DependencyGraphBuilder builder = builders.next();
        compile(builder);
        // TODO: Use a heuristic to decide whether to let the graph builds run in parallel, or sequentially. We will force sequential builds for the time being.
        // Wait for the current config's dependency graph to be built before moving to the next view calc config
        final DependencyGraph graph = builder.getDependencyGraph();
        graph.removeUnnecessaryValues();
        getContext().getGraphs().add(graph);
        builders.remove();
        s_logger.debug("Built {}", graph);
      }
    }
View Full Code Here

    @Override
    protected void compile(final DependencyGraphBuilder builder) {
      final ViewCalculationConfiguration calcConfig = getContext().getViewDefinition().getCalculationConfiguration(builder.getCalculationConfigurationName());
      final Pair<DependencyGraph, Set<ValueRequirement>> graphPair = _previousGraphs.remove(builder.getCalculationConfigurationName());
      if (graphPair != null) {
        final DependencyGraph graph = graphPair.getFirst();
        if (builder.getCompilationContext().getPortfolio() != null) {
          // Remove any invalid terminal outputs from the graph
          final PortfolioIdentifierGatherer gatherer = new PortfolioIdentifierGatherer();
          PortfolioNodeTraverser.parallel(gatherer, getContext().getServices().getExecutorService()).traverse(builder.getCompilationContext().getPortfolio().getRootNode());
          final Set<UniqueId> identifiers = gatherer.getIdentifiers();
          final Set<ValueRequirement> specifics = calcConfig.getSpecificRequirements();
          final Map<ValueSpecification, Set<ValueRequirement>> terminalOutputs = graph.getTerminalOutputs();
          ValueSpecification[] removeValueSpec = null;
          Set<ValueRequirement>[] removeValueReq = null;
          int i = 0;
          for (Map.Entry<ValueSpecification, Set<ValueRequirement>> terminal : terminalOutputs.entrySet()) {
            if (!identifiers.contains(terminal.getKey().getTargetSpecification().getUniqueId())) {
              // Can't be a portfolio requirement
              Set<ValueRequirement> toRemove = null;
              for (ValueRequirement requirement : terminal.getValue()) {
                if (!specifics.contains(requirement)) {
                  // Not a specific requirement
                  if (toRemove == null) {
                    toRemove = Sets.newHashSetWithExpectedSize(terminal.getValue().size());
                  }
                  toRemove.add(requirement);
                }
              }
              if (toRemove != null) {
                if (i == 0) {
                  removeValueSpec = new ValueSpecification[terminalOutputs.size()];
                  removeValueReq = new Set[terminalOutputs.size()];
                }
                removeValueSpec[i] = terminal.getKey();
                removeValueReq[i++] = toRemove;
              }
            }
          }
          if (i > 0) {
            s_logger.info("Removing {} unmatched terminal outputs from {}", i, graph);
            do {
              i--;
              graph.removeTerminalOutputs(removeValueReq[i], removeValueSpec[i]);
            } while (i > 0);
          }
        }
        // Populate the builder with the graph
        builder.setDependencyGraph(graph);
View Full Code Here

          final SubGraphingFilter filter = new SubGraphingFilter(new InvalidTargetDependencyNodeFilter(expiredResolutions));
          final Set<ValueRequirement> missing = new HashSet<ValueRequirement>();
          final Collection<DependencyGraph> graphs = new ArrayList<DependencyGraph>(getContext().getGraphs());
          getContext().getGraphs().clear();
          for (final DependencyGraph graph : graphs) {
            final DependencyGraph filtered = filter.subGraph(graph, missing);
            if (missing.isEmpty()) {
              // No requirements ejected from this graph - keep it
              getContext().getGraphs().add(graph);
            } else {
              s_logger.info("Late changes detected affecting {} requirements", missing.size());
View Full Code Here

  private final ValueSpecification _testValuex2 = ValueSpecification.of("Test", ComputationTargetType.PRIMITIVE, UniqueId.of("test", "x2"), _properties);
  private final ValueSpecification _testValuex3 = ValueSpecification.of("Test", ComputationTargetType.PRIMITIVE, UniqueId.of("test", "x3"), _properties);

  @BeforeMethod
  public void createGraph() {
    _testGraph = new DependencyGraph("Default");
    _testNode = new DependencyNode[5];
    for (int i = 0; i < _testNode.length; i++) {
      final ComputationTarget target = new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", Integer.toString(i)));
      _testNode[i] = new DependencyNode(target);
      _testNode[i].setFunction(MockFunction.getMockFunction(target, "foo"));
View Full Code Here

    assertFalse(ak.equals(bk));
    assertFalse(bk.equals(ak));
  }

  private DependencyGraph createDependencyGraph() {
    final DependencyGraph graph = new DependencyGraph("Default");
    final DependencyNode[] nodes = new DependencyNode[10];
    for (int i = 0; i < nodes.length; i++) {
      final DependencyNode node = new DependencyNode(new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "X")));
      node.setFunction(new MockFunction("Foo" + i, new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "X"))));
      node.addOutputValue(new ValueSpecification(Integer.toString(i), ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo" + i).get()));
      if (i > 0) {
        node.addInputNode(nodes[i - 1]);
        node.addInputValue(new ValueSpecification(Integer.toString(i - 1), ComputationTargetSpecification.of(UniqueId.of("Test", "X")),
            ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo" + (i - 1)).get()));
      }
      graph.addDependencyNode(node);
      nodes[i] = node;
    }
    graph.addTerminalOutput(new ValueRequirement("0", ComputationTargetSpecification.of(UniqueId.of("Test", "X"))),
        new ValueSpecification("0", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo0").get()));
    return graph;
  }
View Full Code Here

        new ValueSpecification("0", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo0").get()));
    return graph;
  }

  public void testDependencyGraphKey_same() {
    final DependencyGraph a = createDependencyGraph();
    final DependencyGraph b = createDependencyGraph();
    // Note: if this test fails because the next two both become true then the DependencyGraphKey class could be redundant
    assertFalse(a.equals(b));
    assertFalse(b.equals(a));
    final DependencyGraphKey ak = new DependencyGraphKey(a, 0);
    final DependencyGraphKey bk = new DependencyGraphKey(b, 0);
    assertTrue(ak.equals(bk));
    assertTrue(bk.equals(ak));
    assertEquals(ak.hashCode(), bk.hashCode());
View Full Code Here

    assertTrue(bk.equals(ak));
    assertEquals(ak.hashCode(), bk.hashCode());
  }

  public void testDependencyGraphKey_initId() {
    final DependencyGraph a = createDependencyGraph();
    final DependencyGraph b = createDependencyGraph();
    final DependencyGraphKey ak = new DependencyGraphKey(a, 1);
    final DependencyGraphKey bk = new DependencyGraphKey(b, 2);
    assertFalse(ak.equals(bk));
    assertFalse(bk.equals(ak));
  }
View Full Code Here

    assertFalse(ak.equals(bk));
    assertFalse(bk.equals(ak));
  }

  public void testDependencyGraphKey_terminals() {
    final DependencyGraph a = createDependencyGraph();
    a.addTerminalOutput(new ValueRequirement("1", ComputationTargetSpecification.of(UniqueId.of("Test", "X"))), new ValueSpecification("1",
        ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo1").get()));
    final DependencyGraph b = createDependencyGraph();
    b.addTerminalOutput(new ValueRequirement("2", ComputationTargetSpecification.of(UniqueId.of("Test", "X"))), new ValueSpecification("2",
        ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo2").get()));
    final DependencyGraphKey ak = new DependencyGraphKey(a, 0);
    final DependencyGraphKey bk = new DependencyGraphKey(b, 0);
    assertFalse(ak.equals(bk));
    assertFalse(bk.equals(ak));
View Full Code Here

TOP

Related Classes of com.opengamma.engine.depgraph.DependencyGraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.