Wikunia / ConstraintSolver.jl

ConstraintSolver in Julia: Blog posts ->
https://opensourc.es/blog/constraint-solver-1
MIT License
136 stars 13 forks source link

Feature VectorAffineFuncton in AllDifferent/Table #268

Closed Wikunia closed 2 years ago

Wikunia commented 2 years ago

Closes #235

It was only possible to have a vector of variables to be alldifferent or part of a TableSet constraint. Sometimes as pointed out by @hakank it makes sense however to support things like [x[i] + i for i in 1:4] in CS.AllDifferentSet().

This internally works as follows:

codecov[bot] commented 2 years ago

Codecov Report

Merging #268 (b4749f8) into master (80a6050) will increase coverage by 0.06%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #268      +/-   ##
==========================================
+ Coverage   97.53%   97.60%   +0.06%     
==========================================
  Files          53       53              
  Lines        4428     4469      +41     
==========================================
+ Hits         4319     4362      +43     
+ Misses        109      107       -2     
Impacted Files Coverage Δ
src/MOI_wrapper/constraints.jl 99.59% <100.00%> (+0.04%) :arrow_up:
src/MOI_wrapper/util.jl 100.00% <100.00%> (ø)
src/ConstraintSolver.jl 99.14% <0.00%> (+0.56%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 80a6050...b4749f8. Read the comment docs.

Wikunia commented 2 years ago

I should make sure that only integer constants and probably coefficients are used. Not sure whether I should disallow it or just warn when it happens though. As an example

[x,1.5y] in CS.TableSet([1,3;])

Could make sense somehow but

[x,1.5y] in CS.AllDifferentSet()

should in principle give a solution to y=1 but the newly created variable 1.5y is integer as the solver doesn't allow continuous variables.