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); }
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); }