org.chocosolver.solver.search.strategy.decision.IbexDecision Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of choco-solver Show documentation
Show all versions of choco-solver Show documentation
Open-source constraint solver.
The newest version!
/*
* This file is part of choco-solver, http://choco-solver.org/
*
* Copyright (c) 2024, IMT Atlantique. All rights reserved.
*
* Licensed under the BSD 4-clause license.
*
* See LICENSE file in the project root for full license information.
*/
package org.chocosolver.solver.search.strategy.decision;
import org.chocosolver.solver.Model;
import org.chocosolver.solver.constraints.real.IbexHandler;
import org.chocosolver.solver.exception.ContradictionException;
import org.chocosolver.solver.variables.RealVar;
import org.chocosolver.solver.variables.Variable;
/**
* A decision that delegates the search process to Ibex
*
* @author Charles Prud'homme
* @since 4.0.6
*/
public class IbexDecision extends Decision {
private static final long serialVersionUID = -4723411613242027369L;
private final IbexHandler handler;
private final Model model;
/**
* Create an decision based on an {@link RealVar}
*/
public IbexDecision(Model model) {
super(1);
this.model = model;
this.handler = model.getIbexHandler();
}
@Override
public Object getDecisionValue() {
return null;
}
@Override
public void apply() throws ContradictionException {
boolean init = branch == 1;
if(handler.nextSolution(init)){
max_branching++;
handler.injectDomain();
}else{
// failure
model.getSolver().throwsException(this, null, "ibex");
}
}
@Override
public void free() {
// nothing to do
}
public boolean inUse(){
return branch > 0;
}
@Override
public String toString() {
return "Delegate to Ibex ...";
}
}