Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.planner.config.localsearch.decider.acceptor;
 
 import java.util.List;
 
 
 @XStreamAlias("acceptor")
 public class AcceptorConfig {
 
     private Acceptor acceptor = null// TODO make into a list
     private Class<AcceptoracceptorClass = null;
 
     @XStreamImplicit(itemFieldName = "acceptorType")
     private List<AcceptorTypeacceptorTypeList = null;
 
     protected Integer completeMoveTabuSize = null;
     protected Integer partialMoveTabuSize = null;
     protected Integer completeUndoMoveTabuSize = null;
     protected Integer partialUndoMoveTabuSize = null;
     protected Integer completePropertyTabuSize = null;
     protected Integer partialPropertyTabuSize = null;
     protected Integer completeSolutionTabuSize = null;
     protected Integer partialSolutionTabuSize = null;
 
     protected String simulatedAnnealingStartingTemperature = null;
 
     protected Double greatDelugeWaterLevelUpperBoundRate = null;
     protected Double greatDelugeWaterRisingRate = null;
 
     public Acceptor getAcceptor() {
         return ;
     }
 
     public void setAcceptor(Acceptor acceptor) {
         this. = acceptor;
     }
 
     public Class<AcceptorgetAcceptorClass() {
         return ;
     }
 
     public void setAcceptorClass(Class<AcceptoracceptorClass) {
         this. = acceptorClass;
     }
 
     public List<AcceptorTypegetAcceptorTypeList() {
         return ;
     }
 
     public void setAcceptorTypeList(List<AcceptorTypeacceptorTypeList) {
         this. = acceptorTypeList;
     }
 
     public Integer getCompleteMoveTabuSize() {
         return ;
     }
 
     public void setCompleteMoveTabuSize(Integer completeMoveTabuSize) {
         this. = completeMoveTabuSize;
     }
 
     public Integer getPartialMoveTabuSize() {
         return ;
     }
 
     public void setPartialMoveTabuSize(Integer partialMoveTabuSize) {
         this. = partialMoveTabuSize;
     }
 
     public Integer getCompleteUndoMoveTabuSize() {
         return ;
    }
    public void setCompleteUndoMoveTabuSize(Integer completeUndoMoveTabuSize) {
        this. = completeUndoMoveTabuSize;
    }
        return ;
    }
    public void setPartialUndoMoveTabuSize(Integer partialUndoMoveTabuSize) {
        this. = partialUndoMoveTabuSize;
    }
        return ;
    }
    public void setCompletePropertyTabuSize(Integer completePropertyTabuSize) {
        this. = completePropertyTabuSize;
    }
        return ;
    }
    public void setPartialPropertyTabuSize(Integer partialPropertyTabuSize) {
        this. = partialPropertyTabuSize;
    }
        return ;
    }
    public void setCompleteSolutionTabuSize(Integer completeSolutionTabuSize) {
        this. = completeSolutionTabuSize;
    }
        return ;
    }
    public void setPartialSolutionTabuSize(Integer partialSolutionTabuSize) {
        this. = partialSolutionTabuSize;
    }
    }
    public void setSimulatedAnnealingStartingTemperature(String simulatedAnnealingStartingTemperature) {
        this. = simulatedAnnealingStartingTemperature;
    }
    }
    public void setGreatDelugeWaterLevelUpperBoundRate(Double greatDelugeWaterLevelUpperBoundRate) {
        this. = greatDelugeWaterLevelUpperBoundRate;
    }
        return ;
    }
    public void setGreatDelugeWaterRisingRate(Double greatDelugeWaterRisingRate) {
        this. = greatDelugeWaterRisingRate;
    }
    // ************************************************************************
    // Builder methods
    // ************************************************************************
    public Acceptor buildAcceptor(EnvironmentMode environmentModeScoreDefinition scoreDefinition) {
        List<AcceptoracceptorList = new ArrayList<Acceptor>();
        if ( != null) {
            acceptorList.add();
        }
        if ( != null) {
            try {
                acceptorList.add(.newInstance());
            } catch (InstantiationException e) {
                throw new IllegalArgumentException("acceptorClass (" + .getName()
                        + ") does not have a public no-arg constructor"e);
            } catch (IllegalAccessException e) {
                throw new IllegalArgumentException("acceptorClass (" + .getName()
                        + ") does not have a public no-arg constructor"e);
            }
        }
        if (( != null && .contains(.))
                ||  != null ||  != null) {
            MoveTabuAcceptor moveTabuAcceptor = new MoveTabuAcceptor();
            moveTabuAcceptor.setUseUndoMoveAsTabuMove(false);
            if ( != null) {
                moveTabuAcceptor.setCompleteTabuSize();
            }
            if ( != null) {
                moveTabuAcceptor.setPartialTabuSize();
            }
            if (environmentMode == .) {
                moveTabuAcceptor.setAssertTabuHashCodeCorrectness(true);
            }
            acceptorList.add(moveTabuAcceptor);
        }
                ||  != null ||  != null) {
            MoveTabuAcceptor undoMoveTabuAcceptor = new MoveTabuAcceptor();
            undoMoveTabuAcceptor.setUseUndoMoveAsTabuMove(true);
            if ( != null) {
                undoMoveTabuAcceptor.setCompleteTabuSize();
            }
            if ( != null) {
                undoMoveTabuAcceptor.setPartialTabuSize();
            }
            if (environmentMode == .) {
                undoMoveTabuAcceptor.setAssertTabuHashCodeCorrectness(true);
            }
            acceptorList.add(undoMoveTabuAcceptor);
        }
                ||  != null ||  != null) {
            PropertyTabuAcceptor propertyTabuAcceptor = new PropertyTabuAcceptor();
            if ( != null) {
                propertyTabuAcceptor.setCompleteTabuSize();
            }
            if ( != null) {
                propertyTabuAcceptor.setPartialTabuSize();
            }
            if (environmentMode == .) {
                propertyTabuAcceptor.setAssertTabuHashCodeCorrectness(true);
            }
            acceptorList.add(propertyTabuAcceptor);
        }
                ||  != null ||  != null) {
            SolutionTabuAcceptor solutionTabuAcceptor = new SolutionTabuAcceptor();
            if ( != null) {
                solutionTabuAcceptor.setCompleteTabuSize();
            }
            if ( != null) {
                solutionTabuAcceptor.setPartialTabuSize();
            }
            if (environmentMode == .) {
                solutionTabuAcceptor.setAssertTabuHashCodeCorrectness(true);
            }
            acceptorList.add(solutionTabuAcceptor);
        }
                ||  != null) {
            SimulatedAnnealingAcceptor simulatedAnnealingAcceptor = new SimulatedAnnealingAcceptor();
            simulatedAnnealingAcceptor.setStartingTemperature(scoreDefinition.parseScore());
            acceptorList.add(simulatedAnnealingAcceptor);
        }
                ||  != null ||  != null) {
            double waterLevelUpperBoundRate = (Double) ObjectUtils.defaultIfNull(
                    , 1.20);
            double waterRisingRate = (Double) ObjectUtils.defaultIfNull(
                    , 0.0000001);
            acceptorList.add(new GreatDelugeAcceptor(waterLevelUpperBoundRatewaterRisingRate));
        }
        if (( != null && .contains(.))) {
            // TODO implement LATE_ACCEPTANCE
            throw new UnsupportedOperationException("LATE_ACCEPTANCE not yet supported.");
        }
        if (acceptorList.size() == 1) {
            return acceptorList.get(0);
        } else if (acceptorList.size() > 1) {
            CompositeAcceptor compositeAcceptor = new CompositeAcceptor();
            compositeAcceptor.setAcceptorList(acceptorList);
            return compositeAcceptor;
        } else {
            SolutionTabuAcceptor solutionTabuAcceptor = new SolutionTabuAcceptor();
            solutionTabuAcceptor.setCompleteTabuSize(1500); // TODO number pulled out of thin air
            if (environmentMode == .) {
                solutionTabuAcceptor.setAssertTabuHashCodeCorrectness(true);
            }
            return solutionTabuAcceptor;
        }
    }
    public void inherit(AcceptorConfig inheritedConfig) {
        // inherited acceptors get compositely added
        if ( == null) {
             = inheritedConfig.getAcceptor();
        }
        if ( == null) {
             = inheritedConfig.getAcceptorClass();
        }
        if ( == null) {
             = inheritedConfig.getAcceptorTypeList();
        } else {
            List<AcceptorTypeinheritedAcceptorTypeList = inheritedConfig.getAcceptorTypeList();
            if (inheritedAcceptorTypeList != null) {
                for (AcceptorType acceptorType : inheritedAcceptorTypeList) {
                    if (!.contains(acceptorType)) {
                        .add(acceptorType);
                    }
                }
            }
        }
        if ( == null) {
             = inheritedConfig.getCompleteMoveTabuSize();
        }
        if ( == null) {
             = inheritedConfig.getPartialMoveTabuSize();
        }
        if ( == null) {
             = inheritedConfig.getCompleteUndoMoveTabuSize();
        }
        if ( == null) {
             = inheritedConfig.getPartialUndoMoveTabuSize();
        }
        if ( == null) {
             = inheritedConfig.getCompletePropertyTabuSize();
        }
        if ( == null) {
             = inheritedConfig.getPartialPropertyTabuSize();
        }
        if ( == null) {
             = inheritedConfig.getCompleteSolutionTabuSize();
        }
        if ( == null) {
             = inheritedConfig.getPartialSolutionTabuSize();
        }
        if ( == null) {
        }
        if ( == null) {
        }
        if ( == null) {
             = inheritedConfig.getGreatDelugeWaterRisingRate();
        }
    }
    public static enum AcceptorType {
        MOVE_TABU,
        UNDO_MOVE_TABU,
        PROPERTY_TABU,
        SOLUTION_TABU,
        SIMULATED_ANNEALING,
        LATE_ACCEPTANCE,
        GREAT_DELUGE,
    }
New to GrepCode? Check out our FAQ X