-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] ArExpression.intVar should allow naming of the variable #783
Comments
Hi, That is not that easy. After executing the following code: Model model = new Model();
IntVar x = model.intVar("x", 0, 2);
IntVar y = model.intVar("y", 0, 2);
IntVar z = x.add(y).intVar(); The variables will named like:
This is because if (me == null) {
IntVar v1 = e1.intVar();
IntVar v2 = e2.intVar();
int[] bounds;
switch (op) {
case ADD:
bounds = VariableUtils.boundsForAddition(v1, v2);
me = model.intVar(model.generateName("sum_exp_"), bounds[0], bounds[1]);
model.arithm(v1, "+", v2, "=", me).post();
break;
case SUB:
bounds = VariableUtils.boundsForSubstraction(v1, v2);
me = model.intVar(model.generateName("sub_exp_"), bounds[0], bounds[1]);
model.arithm(v1, "-", v2, "=", me).post();
break;
case MUL:
// ... So, inputing a Model model = new Model();
IntVar w = model.intVar("w", 0, 2);
IntVar x = model.intVar("x", 0, 2);
IntVar y = model.intVar("y", 0, 2);
IntVar z = x.add(y.sub(w)).intVar(); In that case, no name can be passed to Now, I'm ok with adding a new API with an optional name but internal calls will still rely on default naming and I'm afraid the lack of clarity remains or even increases. |
When creating a variable using an arithmetic expression, the variable would be more identifiable in output if it could be named for a problem domain concept.
Expected behavior
ArExpression.intVar accepts an optional
name
argument, that is used instead of the generated name.Actual behavior
Currently ArExpression.intVar implementations generate a name based on the arithmetic operator being used, which makes it hard to trace in output.
Context
When using a model with multiple arithmetic constraints using the same arithmetic operator, it is unclear in any output which variable was generated by which constraint.
The text was updated successfully, but these errors were encountered: