예제 #1
0
        private Variable variableFor(object key, String name)
        {
            if (allVariables.ContainsKey(key))
            {
                return(allVariables[key]);
            }
            var newVar = solver.MakeNumVar(0.0, double.PositiveInfinity, name + ":" + GetSequence());

            allVariables[key] = newVar;
            return(newVar);
        }
예제 #2
0
        private Variable VariableFor <T>(T key, Func <T, string> name)
            where T : class
        {
            if (allVariables.TryGetValue(key, out Variable? variable))
            {
                return(variable);
            }
            var newVar = solver.MakeNumVar(0.0, double.PositiveInfinity, name(key) + ":" + GetSequence());

            allVariables[key] = newVar;
            return(newVar);
        }