SHARE
TWEET

Untitled

a guest Oct 17th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package fr.ufrsciencestech.badgef;
  7.  
  8. import org.chocosolver.solver.Model;
  9. import org.chocosolver.solver.variables.BoolVar;
  10. import org.chocosolver.solver.variables.IntVar;
  11.  
  12. /**
  13.  *
  14.  * @author sc364347
  15.  */
  16. public class BadgeFV2
  17. {
  18.     public static void main(String args[])
  19.     {
  20.        
  21.         int N = 7;
  22.         int[] data = {4,3,3,2,2,2};
  23.         int K=data.length;
  24.        
  25.         IntVar[] posRow = new IntVar[K];
  26.         IntVar[] posCol =  new IntVar[K];
  27.         Model model =  new Model(2*K + "carre");
  28.         for(int i=0; i<K ; i++)
  29.         {
  30.             posRow[i] = model.intVar("ligne du carrĂ© "+i,0,N-1-data[i]);
  31.             posCol[i] = model.intVar("colonne du carrĂ© "+i,0,N-1-data[i]);
  32.            
  33.         }
  34.        
  35.        
  36.         BoolVar b1 = model.boolVar();
  37.         BoolVar b2 = model.boolVar();
  38.         for(int i=0 ; i<K ; i++)
  39.         {
  40.             IntVar row = posRow[i];
  41.             IntVar row1 = posRow[i+1];
  42.             IntVar row2 = row.add(data[i]).intVar();
  43.             IntVar row21 = row1.add(data[i+1]).intVar();
  44.            
  45.             IntVar col = posCol[i];
  46.             IntVar col1 = posCol[i+1];
  47.             IntVar col2 = col.add(data[i]).intVar();
  48.             IntVar col21 = col1.add(data[i+1]).intVar();
  49.            
  50.             b1 = model.arithm(row2, ">",posRow[i+1]).reify();
  51.             b2 = model.arithm(posRow[i], ">", posRow[i+1]).reify();
  52.            
  53.         }
  54.        
  55.     }
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top