Package com.opengamma.engine

Examples of com.opengamma.engine.ComputationTarget


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

  public void testDependencyNodeKey_inputs() {
    final DependencyNode a = new DependencyNode(new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A")));
    a.setFunction(new MockFunction("Foo", new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A"))));
    a.addInputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    a.addOutputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    a.addOutputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    final DependencyNode b = new DependencyNode(new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A")));
    b.setFunction(new MockFunction("Foo", new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A"))));
    b.addInputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    b.addInputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    b.addOutputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    b.addOutputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    final DependencyNodeKey ak = new DependencyNodeKey(a);
View Full Code Here


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

  public void testDependencyNodeKey_outputs() {
    final DependencyNode a = new DependencyNode(new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A")));
    a.setFunction(new MockFunction("Foo", new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A"))));
    a.addInputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    a.addInputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    a.addOutputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    a.addOutputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    final DependencyNode b = new DependencyNode(new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A")));
    b.setFunction(new MockFunction("Foo", new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A"))));
    b.addInputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    b.addInputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    b.addOutputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    final DependencyNodeKey ak = new DependencyNodeKey(a);
    final DependencyNodeKey bk = new DependencyNodeKey(b);
View Full Code Here

  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()));
View Full Code Here

    assertFalse(bk.equals(ak));
  }

  public void testDependencyGraphKey_node() {
    final DependencyGraph a = createDependencyGraph();
    final DependencyNode n = new DependencyNode(new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A")));
    n.setFunction(new MockFunction("Foo", new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A"))));
    n.addInputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    n.addInputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    n.addOutputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    n.addOutputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    a.addDependencyNode(n);
View Full Code Here

    }
  }

  @Override
  public ExternalIdBundle visitComputationTargetSpecification(final ComputationTargetSpecification specification) {
    final ComputationTarget target = _targetResolver.resolve(specification);
    if (target == null) {
      // Note: Don't convert the unique identifier to an external identifier
      return null;
    }
    if (target.getValue() instanceof ExternalBundleIdentifiable) {
      return ((ExternalBundleIdentifiable) target.getValue()).getExternalIdBundle();
    } else if (target.getValue() instanceof ExternalIdentifiable) {
      return ((ExternalIdentifiable) target.getValue()).getExternalId().toBundle();
    } else {
      // Note: Don't convert the unique identifier to an external identifier.
      return null;
    }
  }
View Full Code Here

  protected boolean run(final GraphBuildingContext context) {
    final ValueRequirement requirement = getValueRequirement();
    boolean missing = false;
    ValueSpecification marketDataSpec = null;
    ComputationTargetSpecification targetSpec = null;
    ComputationTarget target = null;
    Object targetValue = null;
    BlockingOperation.off();
    try {
      targetSpec = getTargetSpecification(context);
      if (targetSpec != null) {
        target = LazyComputationTargetResolver.resolve(context.getCompilationContext().getComputationTargetResolver(), targetSpec);
        if (target != null) {
          targetValue = target.getValue();
        } else {
          targetValue = requirement.getTargetReference().accept(s_getTargetValue);
        }
      } else {
        targetValue = requirement.getTargetReference().accept(s_getTargetValue);
View Full Code Here

  @Override
  public Security resolveSecurity(ExternalId id) {
    ComputationTargetRequirement securityReq = new ComputationTargetRequirement(ComputationTargetType.SECURITY, id);
    ComputationTargetSpecification securitySpec =
        _resolver.getSpecificationResolver().getTargetSpecification(securityReq);
    ComputationTarget target = _resolver.resolve(securitySpec);
    if (target == null) {
      return null;
    }
    return target.getSecurity();
  }
View Full Code Here

        // Being presented with a portfolio like this almost certainly implies a temporary portfolio for which
        // node-level results are not required.
        s_logger.debug("Ignoring portfolio node with no unique ID: {}", portfolioNode);
        return;
      }
      final ComputationTarget target = new ComputationTarget(ComputationTargetType.PORTFOLIO_NODE, portfolioNode);
      final Set<ValueRequirement> visitedRequirements = new HashSet<ValueRequirement>();
      final Set<FunctionExclusionGroup> visitedFunctions = new HashSet<FunctionExclusionGroup>();
      for (final CompiledFunctionDefinition function : _functions) {
        try {
          if (function.getTargetType().isCompatible(ComputationTargetType.PORTFOLIO_NODE) && function.canApplyTo(_context, target)) {
View Full Code Here

      }
    }

    @Override
    public void preOrderOperation(final PortfolioNode parentNode, final Position position) {
      final ComputationTarget target = new ComputationTarget(ComputationTargetType.POSITION, position);
      final Set<ValueRequirement> visitedRequirements = new HashSet<ValueRequirement>();
      final Set<FunctionExclusionGroup> visitedFunctions = new HashSet<FunctionExclusionGroup>();
      for (final CompiledFunctionDefinition function : _functions) {
        try {
          if (function.getTargetType().isCompatible(ComputationTargetType.POSITION) && function.canApplyTo(_context, target)) {
View Full Code Here

  }

  @Override
  protected boolean run(final GraphBuildingContext context) {
    final ValueRequirement requirement = getValueRequirement();
    final ComputationTarget target = getComputationTarget(context);
    if (_resolutions != null) {
      final long startTime = System.nanoTime();
      try {
        final ValueProperties constraints = requirement.getConstraints();
        do {
          final ValueProperties properties = _resolutions.getValueProperties();
          if (constraints.isSatisfiedBy(properties)) {
            s_logger.info("Trying digest resolution {} for {}", properties, requirement);
            final ParameterizedFunction function = _resolutions.getFunction();
            final CompiledFunctionDefinition functionDef = function.getFunction();
            if (!functionDef.getTargetType().isCompatible(target.getType())) {
              s_logger.debug("Function {} type is not compatible with {}", functionDef, target);
              continue;
            }
            final ComputationTarget adjustedTarget = ResolutionRule.adjustTarget(functionDef.getTargetType(), target);
            if (!functionDef.canApplyTo(context.getCompilationContext(), adjustedTarget)) {
              s_logger.debug("Function {} cannot be applied to {}", functionDef, target);
              continue;
            }
            Collection<ValueSpecification> results = functionDef.getResults(context.getCompilationContext(), adjustedTarget);
View Full Code Here

TOP

Related Classes of com.opengamma.engine.ComputationTarget

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.