choco.kernel.common.util.tools
Class VariableUtils

java.lang.Object
  extended by choco.kernel.common.util.tools.VariableUtils

public final class VariableUtils
extends Object


Method Summary
static boolean checkConstant(IntegerVariable v, int value)
           
static boolean checkInteger(VariableType v)
           
static boolean checkReal(VariableType v)
           
static boolean checkSet(VariableType v)
           
static int checkType(VariableType v1, VariableType v2)
          Check the type of each variable and compute a int value
static IntDomainVar createDirVar(Solver solver, TaskVar t1, TaskVar t2)
           
static IntegerVariable createDirVariable(TaskVariable t1, TaskVariable t2, String... boolOptions)
           
static void exch(int[] a, IntDomainVar[] vs, int i, int j)
           
static IntDomainVar[] getBoolDecisionVars(Solver solver)
           
static IntegerVariable[] getCardinalities(SetVariable... vars)
           
static int[] getConstantValues(IntVar... vars)
           
static
<E> E[]
getDecisionList(List<E> decisions, List<E> all, Class<E> clazz)
          Return an array of Variables, from decisions if not empty, otherwise from all.
static IntegerVariable[] getDurationVariables(List<TaskVariable> tasks)
           
static IntegerVariable[] getDurationVariables(TaskVariable... tasks)
           
static IntDomainVar[] getDurationVars(List<TaskVar> tasks)
           
static IntDomainVar[] getDurationVars(TaskVar... tasks)
           
static IntegerVariable[] getEndVariables(List<TaskVariable> tasks)
           
static IntegerVariable[] getEndVariables(TaskVariable... tasks)
           
static IntDomainVar[] getEndVars(List<TaskVar> tasks)
           
static IntDomainVar[] getEndVars(TaskVar... tasks)
           
static IntDomainVar[] getIntVar(Solver solver, Variable[] variables, int begin, int end)
           
static IntDomainVar[] getIntVars(Solver solver)
           
static RealVar[] getRealVars(Solver solver)
           
static SetVar[] getSetVar(Solver solver, Variable[] variables, int begin, int end)
           
static SetVar[] getSetVars(Solver solver)
           
static IntegerVariable[] getStartVariables(List<TaskVariable> tasks)
           
static IntegerVariable[] getStartVariables(TaskVariable... tasks)
           
static IntDomainVar[] getStartVars(List<TaskVar> tasks)
           
static IntDomainVar[] getStartVars(TaskVar... tasks)
           
static TaskVar[] getTaskVar(Solver solver, Variable[] variables, int begin, int end)
           
static TaskVar[] getTaskVars(Solver solver)
           
static IntDomainVar[] getVar(Solver solver, IntegerVariable[] variables, int begin, int end)
           
static SetVar[] getVar(Solver solver, SetVariable[] variables, int begin, int end)
           
static TaskVar[] getVar(Solver solver, TaskVariable[] variables, int begin, int end)
           
static Var[] getVar(Solver solver, Variable[] variables, int begin, int end)
           
static int partition(int[] a, IntDomainVar[] vs, int left, int right)
           
static void quicksort(int[] a, IntDomainVar[] vs, int left, int right)
          A quickSort algorithm for sorting a table of variable according to a table of integers.
static void reverse(int[] tab, IntDomainVar[] vs)
          Reverse a table of integer and variables (use for api on linear combination)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getVar

public static Var[] getVar(Solver solver,
                           Variable[] variables,
                           int begin,
                           int end)

getVar

public static IntDomainVar[] getVar(Solver solver,
                                    IntegerVariable[] variables,
                                    int begin,
                                    int end)

getVar

public static SetVar[] getVar(Solver solver,
                              SetVariable[] variables,
                              int begin,
                              int end)

getVar

public static TaskVar[] getVar(Solver solver,
                               TaskVariable[] variables,
                               int begin,
                               int end)

getIntVar

public static IntDomainVar[] getIntVar(Solver solver,
                                       Variable[] variables,
                                       int begin,
                                       int end)

getSetVar

public static SetVar[] getSetVar(Solver solver,
                                 Variable[] variables,
                                 int begin,
                                 int end)

getTaskVar

public static TaskVar[] getTaskVar(Solver solver,
                                   Variable[] variables,
                                   int begin,
                                   int end)

checkInteger

public static boolean checkInteger(VariableType v)

checkSet

public static boolean checkSet(VariableType v)

checkReal

public static boolean checkReal(VariableType v)

checkType

public static int checkType(VariableType v1,
                            VariableType v2)
Check the type of each variable and compute a int value

Parameters:
v1 - type of the first variable
v2 - type of he second variable
Returns:
a value corresponding to the whole type

if the type is integer return 1 * position if the type is set return 2 * position if the type is real return 3 * position

where position is 10 for v1 and 1 for v2


quicksort

public static void quicksort(int[] a,
                             IntDomainVar[] vs,
                             int left,
                             int right)
A quickSort algorithm for sorting a table of variable according to a table of integers.

Parameters:
a - : the integer table to be sorted
vs - : the intvar table to be sorted according a
left -
right -

partition

public static int partition(int[] a,
                            IntDomainVar[] vs,
                            int left,
                            int right)

exch

public static void exch(int[] a,
                        IntDomainVar[] vs,
                        int i,
                        int j)

reverse

public static void reverse(int[] tab,
                           IntDomainVar[] vs)
Reverse a table of integer and variables (use for api on linear combination)

Parameters:
tab - array of integer to reverse
vs - array of variables to reverse

createDirVariable

public static IntegerVariable createDirVariable(TaskVariable t1,
                                                TaskVariable t2,
                                                String... boolOptions)

getStartVariables

public static IntegerVariable[] getStartVariables(TaskVariable... tasks)

getDurationVariables

public static IntegerVariable[] getDurationVariables(TaskVariable... tasks)

getEndVariables

public static IntegerVariable[] getEndVariables(TaskVariable... tasks)

getStartVariables

public static IntegerVariable[] getStartVariables(List<TaskVariable> tasks)

getDurationVariables

public static IntegerVariable[] getDurationVariables(List<TaskVariable> tasks)

getEndVariables

public static IntegerVariable[] getEndVariables(List<TaskVariable> tasks)

createDirVar

public static IntDomainVar createDirVar(Solver solver,
                                        TaskVar t1,
                                        TaskVar t2)

getStartVars

public static IntDomainVar[] getStartVars(TaskVar... tasks)

getDurationVars

public static IntDomainVar[] getDurationVars(TaskVar... tasks)

getEndVars

public static IntDomainVar[] getEndVars(TaskVar... tasks)

getStartVars

public static IntDomainVar[] getStartVars(List<TaskVar> tasks)

getDurationVars

public static IntDomainVar[] getDurationVars(List<TaskVar> tasks)

getEndVars

public static IntDomainVar[] getEndVars(List<TaskVar> tasks)

getIntVars

public static IntDomainVar[] getIntVars(Solver solver)

getSetVars

public static SetVar[] getSetVars(Solver solver)

getRealVars

public static RealVar[] getRealVars(Solver solver)

getTaskVars

public static TaskVar[] getTaskVars(Solver solver)

getDecisionList

public static <E> E[] getDecisionList(List<E> decisions,
                                      List<E> all,
                                      Class<E> clazz)
Return an array of Variables, from decisions if not empty, otherwise from all. clazz is mandatory for array creation.

Type Parameters:
E -
Parameters:
decisions - list of decisions variables (can be empty)
all - list of all variables of the solver
clazz - class of objects in decisions and all
Returns:
an array of E

getConstantValues

public static int[] getConstantValues(IntVar... vars)

getCardinalities

public static IntegerVariable[] getCardinalities(SetVariable... vars)

checkConstant

public static boolean checkConstant(IntegerVariable v,
                                    int value)

getBoolDecisionVars

public static IntDomainVar[] getBoolDecisionVars(Solver solver)


Copyright © 2012. All Rights Reserved.