Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package fr.ufrsciencestech.badgef;
- import org.chocosolver.solver.Model;
- import org.chocosolver.solver.variables.BoolVar;
- import org.chocosolver.solver.variables.IntVar;
- /**
- *
- * @author sc364347
- */
- public class BadgeFV2
- {
- public static void main(String args[])
- {
- int N = 7;
- int[] data = {4,3,3,2,2,2};
- int K=data.length;
- IntVar[] posRow = new IntVar[K];
- IntVar[] posCol = new IntVar[K];
- Model model = new Model(2*K + "carre");
- for(int i=0; i<K ; i++)
- {
- posRow[i] = model.intVar("ligne du carré "+i,0,N-1-data[i]);
- posCol[i] = model.intVar("colonne du carré "+i,0,N-1-data[i]);
- }
- BoolVar b1 = model.boolVar();
- BoolVar b2 = model.boolVar();
- for(int i=0 ; i<K ; i++)
- {
- IntVar row = posRow[i];
- IntVar row1 = posRow[i+1];
- IntVar row2 = row.add(data[i]).intVar();
- IntVar row21 = row1.add(data[i+1]).intVar();
- IntVar col = posCol[i];
- IntVar col1 = posCol[i+1];
- IntVar col2 = col.add(data[i]).intVar();
- IntVar col21 = col1.add(data[i+1]).intVar();
- b1 = model.arithm(row2, ">",posRow[i+1]).reify();
- b2 = model.arithm(posRow[i], ">", posRow[i+1]).reify();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement