Package net.sf.cpsolver.ifs.model

Examples of net.sf.cpsolver.ifs.model.Variable


   
    /** Variable selection */
    public Variable selectVariable(Solution solution) {
        Model model = solution.getModel();
        if (model.nrUnassignedVariables()==0) return null;
        Variable variable = null;
        for (Enumeration e=model.unassignedVariables().elements();e.hasMoreElements();) {
            Variable v = (Variable)e.nextElement();
            if (variable==null || v.compareTo(variable)<0) variable = v;
        }
        return variable;
    }
View Full Code Here


        boolean acceptConflicts = solution.getModel().getBestUnassignedVariables()>0;
        Model model = solution.getModel();
        double bestEval = 0.0;
        Vector best = null;
        for (Enumeration e=model.variables().elements();e.hasMoreElements();) {
            Variable variable = (Variable)e.nextElement();
            Value assigned = variable.getAssignment();
            double assignedVal = (assigned==null?iConflictWeight:iValueWeight*assigned.toDouble());
            for (Enumeration f=variable.values().elements();f.hasMoreElements();) {
                Value value = (Value)f.nextElement();
                if (value.equals(assigned)) continue;
                double eval = iValueWeight*value.toDouble() - assignedVal;
                if (acceptConflicts) {
                    Set conflicts = model.conflictValues(value);
View Full Code Here

            v2.addAll(iVariable.values());
            iValEn = new RandomEnumeration(v2, iRandomOrder);
        }
        Object object = iValEn.nextElement();
        if (object instanceof Variable) {
            Variable anotherVariable = (Variable)ToolBox.random(model.variables());
            if (iVariable.equals(anotherVariable)) return null;
            return ((Swapable)iVariable).findSwap(anotherVariable);
        } else {
            Value value = (Value)object;
            if (value.equals(iVariable.getAssignment())) return null;
View Full Code Here

    }
    public void init(Solver solver) {}
    public Neighbour selectNeighbour(Solution solution) {
        Model model = solution.getModel();
        boolean canConflict = model.nrAssignedVariables()!=0;
        Variable variable = (Variable)ToolBox.random(model.variables());
        Value value = (Value)ToolBox.random(variable.values());
        if (value.equals(variable.getAssignment())) return null;
        Set conflicts = model.conflictValues(value);
        double eval = iValueWeight * value.toDouble();
        if (variable.getAssignment()!=null)
            eval -= iValueWeight * variable.getAssignment().toDouble();
        else
            eval -= iConflictWeight;
        eval += iConflictWeight * model.conflictValues(value).size();
        return new ItcSimpleNeighbour(variable,value,eval);
    }
View Full Code Here

    /** Initialization */
    public void init(Solver solver) {}
    /** Neighbour selection */
    public Neighbour selectNeighbour(Solution solution) {
        Model model = solution.getModel();
        Variable variable = (Variable)ToolBox.random(model.variables());
        Value value = (Value)ToolBox.random(variable.values());
        if (value.equals(variable.getAssignment())) return null;
        if (model.inConflict(value)) return null;
        return new ItcSimpleNeighbour(variable,value);
    }
View Full Code Here

    /** Initialization */
    public void init(Solver solver) {}
    /** Neighbour selection */
    public Neighbour selectNeighbour(Solution solution) {
        Model model = solution.getModel();
        Variable variable = (Variable)ToolBox.random(model.variables());
        if (!(variable instanceof Swapable)) return null;
        Variable anotherVariable = (Variable)ToolBox.random(model.variables());
        if (variable.equals(anotherVariable)) return null;
        return ((Swapable)variable).findSwap(anotherVariable);
    }
View Full Code Here

    }

    private long getTemperatureLength(Solver solver) {
        long len = 0;
        for (Enumeration e = solver.currentSolution().getModel().variables().elements(); e.hasMoreElements();) {
            Variable variable = (Variable) e.nextElement();
            len += variable.values().size();
        }
        sLog.info("Temperature length " + len);
        return len;
    }
View Full Code Here

    }
   
    private long getTemperatureLength(Solver solver) {
        long len = 0;
        for (Enumeration e=solver.currentSolution().getModel().variables().elements();e.hasMoreElements();) {
            Variable variable = (Variable)e.nextElement();
            len += variable.values().size();
        }
        sLog.info("Temperature length "+len);
        return len;
    }
View Full Code Here

TOP

Related Classes of net.sf.cpsolver.ifs.model.Variable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.