All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.chocosolver.solver.constraints.IRealConstraintFactory Maven / Gradle / Ivy

There is a newer version: 4.10.17
Show newest version
/*
 * This file is part of choco-solver, http://choco-solver.org/
 *
 * Copyright (c) 2019, IMT Atlantique. All rights reserved.
 *
 * Licensed under the BSD 4-clause license.
 *
 * See LICENSE file in the project root for full license information.
 */
package org.chocosolver.solver.constraints;

import org.chocosolver.solver.constraints.real.PropScalarMixed;
import org.chocosolver.solver.constraints.real.RealConstraint;
import org.chocosolver.solver.variables.Variable;

/**
 * Interface to make constraints over RealVar
 *
 * A kind of factory relying on interface default implementation to allow (multiple) inheritance
 *
 * @author Jean-Guillaume FAGES
 * @since 4.0.0
 */
public interface IRealConstraintFactory {

	/**
	 * Creates a RealConstraint to model one or more continuous functions, separated with semi-colon ";"
	 * 
* A function is a string declared using the following format: *
- the '{i}' tag defines a variable, where 'i' is an explicit index the array of variables vars, *
- one or more operators :'+,-,*,/,=,<,>,<=,>=,exp( ),ln( ),max( ),min( ),abs( ),cos( ), sin( ),...' *
A complete list is available in the documentation of IBEX. *

* * Example to express the system: *
x*y + sin(x) = 1; *
ln(x)+[-0.1,0.1] >=2.6; *
*
realIbexGenericConstraint("({0}*{1})+sin({0})=1.0;ln({0}+[-0.1,0.1])>=2.6", x,y); * * @param functions list of functions, separated by a semi-colon * @param rvars a list of real variables */ default RealConstraint realIbexGenericConstraint(String functions, Variable... rvars) { return new RealConstraint(functions, rvars); } /** * Creates a RealConstraint to model one or more continuous functions, separated with semi-colon ";" *
* A function is a string declared using the following format: *
- the '{i}' tag defines a variable, where 'i' is an explicit index the array of variables vars, *
- one or more operators :'+,-,*,/,=,<,>,<=,>=,exp( ),ln( ),max( ),min( ),abs( ),cos( ), sin( ),...' *
A complete list is available in the documentation of IBEX. *

* * Example to express the system: *
x*y + sin(x) = 1; *
ln(x)+[-0.1,0.1] >=2.6; *
*
realIbexGenericConstraint("({0}*{1})+sin({0})=1.0;ln({0}+[-0.1,0.1])>=2.6", x,y); * * @param functions list of functions, separated by a semi-colon * @param rvars a list of real variables */ default RealConstraint ibex(String functions, Variable... rvars) { return realIbexGenericConstraint(functions, rvars); } /** * Creates a linear equation constraint over RealVar, IntVar or BoolVar * which ensures that Sum(vars[i]*coeffs[i]) op bound * * @param vars a collection of variable (RealVar, IntVar, BoolVar are accepted) * @param coeffs a collection of double, for which |vars|=|coeffs| * @param op an operator in {"=", ">=", "<="} * @param bound a double * @return a scalar constraint */ default Constraint scalar(Variable[] vars, double[] coeffs, String op, double bound){ return new Constraint(ConstraintsName.MIXEDSCALAR, new PropScalarMixed(vars, coeffs, Operator.get(op), bound)); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy