<commit_before>/*
 * (c) Copyright <NAME>, Germany. Contact: <EMAIL>.
 *
 * Created on 09.02.2004
 */
package net.finmath.montecarlo.interestrate;

import net.finmath.montecarlo.interestrate.products.AbstractLIBORMonteCarloProduct;
import net.finmath.stochastic.RandomVariable;
import net.finmath.stochastic.Scalar;

/**
 * A class for calibration products, that is a triple (P,V,w) where P is a product, V is a target value and w is a weight.
 *
 * @author <NAME>
 */
public class CalibrationProduct {

	private final String 	name;
	private final AbstractLIBORMonteCarloProduct		product;
	private final RandomVariable				targetValue;
	private final double								weight;

	/**
	 * Construct a calibration product. A calibration product consists of a product implementing {@link AbstractLIBORMonteCarloProduct}, a target value
	 * given as {@link RandomVariable} and a weight. In addition you may give a short name which may be printed by the logger.
	 *
	 * @param name A short name (for example a "SYMBOL" representing the product.
	 * @param product The product.
	 * @param targetValue The target value.
	 * @param weight The calibration weight.
	 */
	public CalibrationProduct(String name, AbstractLIBORMonteCarloProduct product, RandomVariable targetValue, double weight) {
		super();
		this.name			= name;
		this.product		= product;
		this.targetValue	= targetValue;
		this.weight			= weight;
	}

	public CalibrationProduct(String name, AbstractLIBORMonteCarloProduct product, double targetValue, double weight) {
		this(name, product, new Scalar(targetValue), weight);
	}

	public CalibrationProduct(AbstractLIBORMonteCarloProduct product, RandomVariable targetValue, double weight) {
		this(null, product, targetValue, weight);
	}

	public CalibrationProduct(AbstractLIBORMonteCarloProduct product, double targetValue, double weight) {
		this(product, new Scalar(targetValue), weight);
	}

	/**
	 * The method returns a short name for this calibration product. If no short name was given, the method returns <code>getProduct().toString()</code>.
	 *
	 * @return A short name for this calibration product. If no short name was given, the method returns <code>getProduct().toString()</code>
	 */
	public String getName() {
		if(name != null) return name;
		else return product.toString();
	}

	/**
	 * @return the product.
	 */
	public AbstractLIBORMonteCarloProduct getProduct() {
		return product;
	}

	/**
	 * @return the target value.
	 */
	public RandomVariable getTargetValue() {
		return targetValue;
	}

	/**
	 * @return the calibrationWeight
	 */
	public double getWeight() {
		return weight;
	}

	@Override
	public String toString() {
		return "CalibrationProduct [product=" + getProduct()
		+ ", targetValue=" + getTargetValue()<commit_msg>Added priority to calibration products (optional).<commit_after>/*
 * (c) Copyright <NAME>, Germany. Contact: <EMAIL>.
 *
 * Created on 09.02.2004
 */
package net.finmath.montecarlo.interestrate;

import net.finmath.montecarlo.interestrate.products.AbstractLIBORMonteCarloProduct;
import net.finmath.stochastic.RandomVariable;
import net.finmath.stochastic.Scalar;

/**
 * A class for calibration products, that is a triple (P,V,w) where P is a product, V is a target value and w is a weight.
 *
 * @author <NAME>
 */
public class CalibrationProduct {

	private final String 	name;
	private final AbstractLIBORMonteCarloProduct		product;
	private final RandomVariable						targetValue;
	private final double								weight;
	private final Integer								priority;

	/**
	 * Construct a calibration product. A calibration product consists of a product implementing {@link AbstractLIBORMonteCarloProduct}, a target value
	 * given as {@link RandomVariable} and a weight. In addition you may give a short name which may be printed by the logger.
	 *
	 * @param name A short name (for example a "SYMBOL" representing the product.
	 * @param product The product.
	 * @param targetValue The target value.
	 * @param weight The calibration weight.
	 * @param priority The priority (may be used when submitting the product for calculation)
	 */
	public CalibrationProduct(String name, AbstractLIBORMonteCarloProduct product, RandomVariable targetValue, double weight, int priority) {
		super();
		this.name			= name;
		this.product		= product;
		this.targetValue	= targetValue;
		this.weight			= weight;
		this.priority		= priority;
	}

	public CalibrationProduct(String name, AbstractLIBORMonteCarloProduct product, RandomVariable targetValue, double weight) {
		this(name, product, targetValue, weight, 0);
	}
	
	public CalibrationProduct(String name, AbstractLIBORMonteCarloProduct product, double targetValue, double weight) {
		this(name, product, new Scalar(targetValue), weight);
	}

	public CalibrationProduct(AbstractLIBORMonteCarloProduct product, RandomVariable targetValue, double weight) {
		this(null, product, targetValue, weight);
	}

	public CalibrationProduct(AbstractLIBORMonteCarloProduct product, double targetValue, double weight) {
		this(product, new Scalar(targetValue), weight);
	}

	/**
	 * The method returns a short name for this calibration product. If no short name was given, the method returns <code>getProduct().toString()</code>.
	 *
	 * @return A short name for this calibration product. If no short name was given, the method returns <code>getProduct().toString()</code>
	 */
	public String getName() {
		if(name != null) return name;
		else return product.toString();
	}

	/**
	 * @return the product.
	 */
	public AbstractLIBORMonteCarloProduct getProduct() {
		return product;
	}

	/**
	 * @return the target value.
	 */
	public RandomVariable getTargetValue() {
		return targetValue;
	}

	/**
	 * @return the calibrationWeight
	 */
	public double getWeight() {
		return weight;
	}

	/**
	 * @return the priority
	 */
	public Integer getPriority() {
		return priority;
	}

	@Override
	public String toString() {
		return "CalibrationProduct [product=" + getProduct()
		+ ", targetValue=" + getTargetValue()
{'fraction_non_alphanumeric': 0.09376042709376042, 'fraction_numerical': 0.0028361695028361693, 'mean_word_length': 4.405770964833183, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6616687', 'n_tokens_mistral': 1808, 'n_tokens_neox': 1652, 'n_words': 579}