我如何进行实验以尽量减少使用 choco 求解器?

How can i put an experiession to minimize using choco solver?

我使用choco solver version 2.1.5,我想做一个最小化我的变量之和的经验。我该怎么做?

也许你从sourceforge下载了那个版本:那里,我们建议访问 http://choco-solver.org 我们可以在哪里下载更新的。

With the more recent version 4.10.7, released on Oct 11 2021, 
you may experiment with something like this:


    Model model = new Model();
            
    IntVar x = model.intVar("x", 3, 10, false);
    IntVar y = model.intVar("y", 2, 20, false);
    IntVar sum = model.intVar("sum", 1, 50, false);
    
    model.arithm(x, "+", y, "=", sum).post();
            
    Solver solver = model.getSolver();  
    model.setObjective(Model.MINIMIZE, sum);
    
    while (solver.solve()) {
        System.out.println(" x = " + x.getValue());
        System.out.println(" y = " + y.getValue());
        System.out.println(" sum = " + sum.getValue());
    } 


It will print:

    x = 3
    y = 2
    sum = 5