samples.tutorials.lns.lns
Class LNSCPSolver

java.lang.Object
  extended by choco.cp.solver.CPSolver
      extended by samples.tutorials.lns.lns.LNSCPSolver
All Implemented Interfaces:
IPretty, ISolutionDisplay, IMeasures, IOptimizationMeasures, IPreSolveMeasures, ISearchMeasures, ISolutionMeasures, Solver

public class LNSCPSolver
extends CPSolver

A Large Neighborhood Search approach encapsulating a CP solver. First, the CP solver computes an initial set of solutions. Then, it is re-used to explore several neighborhoods around these solutions, in hope to locally improve these solutions. The neighborhood of a solution is obtained by restricting the search space around the solution e.g. by fixing some of the variables to their values in the solution and by relaxing the others. todo 1 make LNSCPSolver implement Solver and remove the inheritance from CPSolver: aggregate the statistics of the encapsulated CPSolver OR todo 2 make LNS a BranchingStrategy with restarts

Author:
Sophie Demassey

Field Summary
 
Fields inherited from class choco.cp.solver.CPSolver
configuration, FINEST, GOAL, mapconstraints, mapvariables, mod2sol, model, PROPAGATION, propagationEngine, readingTime, SEARCH, SILENT, SOLUTION, strategy, tempGoal
 
Fields inherited from interface choco.kernel.solver.Solver
DEFAULT_SOLUTION_CHECKER, LOGGER
 
Constructor Summary
LNSCPSolver(Configuration configuration)
           
LNSCPSolver(IEnvironment env, Configuration configuration)
           
 
Method Summary
 void addNeighborhood(Neighborhood neighborhood)
          add a neighborhood operator to apply to the solutions
 void addNeighborhood(NeighborhoodOperator operator)
          add a neighborhood operator to apply to the solutions using the default branching strategy and a default run number of 5
 void addNeighborhood(NeighborhoodOperator operator, AbstractIntBranchingStrategy strategy, int impact)
          add a neighborhood operator to apply to the solutions
protected  Boolean optimize(boolean maximize, Var obj, boolean restart)
          launch the large neighborhood search
 void read(Model model)
          read the model and load it in the delegate solver
 Boolean searchNeighborhood(Neighborhood neighborhood, Solution solution, int objToImprove)
          Explore one neighborhood defined by an operator applied to a solution: the search space of the solver is restricted around the solution by the neighborhood operator, and the objective is bounded by the value to improve upon.
 
Methods inherited from class choco.cp.solver.CPSolver
_to, _to, addConstraint, addConstraint, addGoal, addIntConstant, addIntVar, addNogood, addrealConstant, addRealVar, addSetVar, around, attachGoal, checkDecisionVariables, checkSolution, checkSolution, clear, clearGoals, constraintsToString, contains, cos, createBinTreeIntVar, createBinTreeIntVar, createBooleanVar, createBoundIntVar, createBoundSetVar, createEnumIntVar, createEnumIntVar, createEnumSetVar, createEquation, createFCLargeConstraint, createIntegerConstant, createIntVar, createIntVarAddCste, createIntVarTimeCste, createListIntVar, createListIntVar, createMakespan, createNotBooleanVar, createRealConstant, createRealCos, createRealIntegerPower, createRealIntervalConstant, createRealMinus, createRealMult, createRealPlus, createRealSin, createRealVal, createSetVar, createSetVar, createTaskVar, cst, cst, decisionOnExpression, eq, eq, eq, eq, eq, eq, eq, eq, eq, eq, eqCard, eqCard, eraseConstraint, existsSolution, feasiblePairAC, feasiblePairAC, feasibleTupleAC, feasibleTupleAC, feasibleTupleFC, feasPairAC, feasPairAC, feasPairAC, feasPairAC, feasTupleAC, feasTupleFC, flushLogs, generateDefaultGoal, generateDefaultIntGoal, generateDefaultRealGoal, generateSearchLoop, generateSearchStrategy, generateSetDefaultGoal, geq, geq, geq, geq, geq, geq, geq, geq, geqCard, geqCard, getBackTrackCount, getBooleanVariables, getConfiguration, getConstraintIterator, getCstr, getEncounteredLimit, getEnvironment, getFailCount, getFirstSolution, getHorizon, getIndexfactory, getInitialPropagationTimeCount, getIntConstant, getIntConstantSet, getIntConstraint, getIntConstraintIterator, getIntDecisionVars, getIntVar, getIntVarIndex, getIntVarIndex, getIntVarIterator, getIntVarQuick, getLoggingMaxDepth, getMakespan, getMakespanValue, getModel, getNbBooleanVars, getNbConstants, getNbConstraints, getNbIntConstants, getNbIntConstraints, getNbIntVars, getNbRealConstants, getNbRealVars, getNbSetVars, getNbSolutions, getNbTaskVars, getNbVars, getNodeCount, getNogoodStore, getObjective, getObjectiveValue, getOptimumValue, getPrecision, getPropagationEngine, getReadingTimeCount, getRealConstant, getRealConstantSet, getRealDecisionVars, getRealVar, getRealVarIndex, getRealVarIterator, getRealVarQuick, getRecomputationGap, getReduction, getRestartCount, getSearchStrategy, getSetDecisionVars, getSetVar, getSetVarIndex, getSetVarIterator, getSetVarQuick, getSolutionCount, getTaskDecisionVars, getTaskVar, getTaskVarIterator, getTaskVarQuick, getTimeCount, getVar, getVar, getVar, getVar, getVar, getVar, getVar, getVar, getVar, getVar, getWorldIndex, gt, gt, gt, infeasiblePairAC, infeasiblePairAC, infeasibleTupleAC, infeasibleTupleAC, infeasibleTupleFC, infeasPairAC, infeasPairAC, infeasPairAC, infeasPairAC, infeasTupleAC, infeasTupleFC, initNogoodBase, initReading, isCompletelyInstantiated, isConsistent, isEncounteredLimit, isFeasible, isObjectiveOptimal, isOptimizationSolver, isUniqueReading, launch, leq, leq, leq, leq, leq, leq, leqCard, leqCard, lt, lt, lt, makeBinRelation, makeBinRelation, makeBinRelation, makeBinRelation, makeConstantIntVar, makeConstantIntVar, makeEquation, makeLargeRelation, makeLargeRelation, makeMapespanConstraint, makeRelation, makeSConstraint, makeSConstraint, makeSConstraintAndOpposite, makeSConstraintAndOpposite, makeTupleAC, makeTupleFC, maximize, maximize, minimize, minimize, minus, minus, minus, minus, monitorBackTrackLimit, monitorFailLimit, monitorNodeLimit, monitorTimeLimit, mult, mult, neq, neq, neq, neq, neq, neq, nextSolution, occurence, plus, plus, plus, plus, plus, post, post, post, postCut, postMakespanConstraint, postRedundantSetConstraints, postTaskConsistencyConstraints, power, preceding, preceding, preceding, pretty, printRuntimeStatistics, propagate, recordSolution, reifiedIntConstraint, reifiedIntConstraint, relationPairAC, relationPairAC, relationTupleAC, relationTupleAC, relationTupleFC, resetSearchStrategy, restoreSolution, runtimeStatistics, scalar, scalar, setBackTrackLimit, setCardReasoning, setDoMaximize, setFailLimit, setFeasible, setFirstSolution, setGeometricRestart, setGeometricRestart, setHorizon, setIlogGoal, setLoggingMaxDepth, setLubyRestart, setLubyRestart, setMakespan, setMaximizationObjective, setMinimizationObjective, setModel, setNodeLimit, setObjective, setPrecision, setRandomSelectors, setRandomSelectors, setRandomSelectors, setRecomputation, setRecomputationGap, setRecordNogoodFromRestart, setReduction, setRestart, setRestartLimit, setSolutionDisplay, setSolutionPoolCapacity, setTimeLimit, setUniqueReading, setValIntIterator, setValIntSelector, setValRealIterator, setValRealSelector, setValSetIterator, setValSetSelector, setVarIntSelector, setVarRealSelector, setVarSetSelector, setVerbosity, sin, solutionToString, solve, solve, solveAll, sum, sum, summaryToString, toString, useRecomputation, varsToString, worldPop, worldPopDuringPropagation, worldPopUntil, worldPush, worldPushDuringPropagation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LNSCPSolver

public LNSCPSolver(Configuration configuration)

LNSCPSolver

public LNSCPSolver(IEnvironment env,
                   Configuration configuration)
Method Detail

read

public void read(Model model)
read the model and load it in the delegate solver

Specified by:
read in interface Solver
Overrides:
read in class CPSolver
Parameters:
model - the model of the problem

optimize

protected Boolean optimize(boolean maximize,
                           Var obj,
                           boolean restart)
launch the large neighborhood search

Overrides:
optimize in class CPSolver
Parameters:
maximize - optimization direction: true if maximization , false if minimization
obj - the objective variable
restart - unconsidered
Returns:
FALSE if infeasibility is proved, TRUE if at least one solution is found, null otherwise

addNeighborhood

public void addNeighborhood(NeighborhoodOperator operator,
                            AbstractIntBranchingStrategy strategy,
                            int impact)
add a neighborhood operator to apply to the solutions

Parameters:
operator - the operator type to build the neighborhood
strategy - the branching heuristic to explore the neighborhood // todo branching type rather than branching object
impact - the number of runs the operator will apply without improvement

addNeighborhood

public void addNeighborhood(NeighborhoodOperator operator)
add a neighborhood operator to apply to the solutions using the default branching strategy and a default run number of 5

Parameters:
operator - the operator type

addNeighborhood

public void addNeighborhood(Neighborhood neighborhood)
add a neighborhood operator to apply to the solutions

Parameters:
neighborhood - the operator

searchNeighborhood

public Boolean searchNeighborhood(Neighborhood neighborhood,
                                  Solution solution,
                                  int objToImprove)
Explore one neighborhood defined by an operator applied to a solution: the search space of the solver is restricted around the solution by the neighborhood operator, and the objective is bounded by the value to improve upon. The restricted search space is then explored by limited backtracking.

Parameters:
neighborhood - the neighborhood operator
solution - the solution around which the neighborhood is explored
objToImprove - the objective value to improve upon (ex: incumbent or solution objective value)
Returns:
FALSE if infeasibility is proved, TRUE if one improving solution is found, null otherwise


Copyright © 2012. All Rights Reserved.