CrazyEngineers
  • how to execute a jacop?

    Reya

    Reya

    @reya-SMihdC
    Updated: Oct 22, 2024
    Views: 1.9K
    Hi fnds,do anybody know how to execute the java constraint program in netbeans 6.8? i searched in google but i could not find out..
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Manish Goyal

    MemberSep 13, 2010

    Sory didn't get you
    what do you mean by java constraint program?
    Are you sure? This action cannot be undone.
    Cancel
  • Reya

    MemberSep 13, 2010

    The constraint programming approach is to search for the values of all the unknown variables in which the large no of constraints should be satisfied at the same time.JaCoP library provides
    the constraint programming implemeted in java..And so it is called as java constraint program.
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberSep 13, 2010

    have you set the class path?
    Are you sure? This action cannot be undone.
    Cancel
  • Reya

    MemberSep 13, 2010

    what for class path here?do v have to mention the class path in netbeans?
    Are you sure? This action cannot be undone.
    Cancel
  • Reya

    MemberSep 13, 2010

    I have included the JaCoP library in netbeans..But still i get the error in the first line(import JaCoP -3.0-RC1.*; )of my prog.
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberSep 13, 2010

    Tell me exactly the error message it is showing ,if it is showing message like

    package doesnot exist then I think there is problem related to classpath otherwise there may be some syntax related problem

    Try this
    import JaCop.*;
    or import JaCop.core.*;
    Are you sure? This action cannot be undone.
    Cancel
  • Reya

    MemberSep 14, 2010

    i didnt get the error as package doesnt exists..

    import JaCoP-3.0-RC1.*;
    import java.util.*;
    public class Main {
    static Main m = new Main ();
    public static void main (String[] args) {
    FDstore store = new FDstore(); // define FD store
    int size = 4;
    // define FDVs
    FDV[] v = new FDV[size];
    for (int i=0; i<size; i++)
    v = new FDV(store, "v"+i, 1, size);
    // define constraints
    store.impose( new XneqY(v[0], v[1]) );
    store.impose( new XneqY(v[0], v[2]) );
    store.impose( new XneqY(v[1], v[2]) );
    store.impose( new XneqY(v[1], v[3]) );
    store.impose( new XneqY(v[2], v[3]) );
    // search for a solution and print results
    ArrayList<FDV> list = new ArrayList<FDV>();
    for(FDV var : v) list.add(var);
    boolean result = Solver.searchOne(store, list, new SearchOne(),new IndomainMin(), new Delete());
    if ( result )
    System.out.println("Solution: " + list + "\n*** Yes");
    else
    System.out.println("*** No");
    }
    }

    error message:

    E:\Documents and Settings\SSN\My Documents\NetBeansProjects\JavaApplication15\src\javaapplication15\Main.java:8: '.' expected
    import JaCoP-3.0-RC1.*;
    E:\Documents and Settings\SSN\My Documents\NetBeansProjects\JavaApplication15\src\javaapplication15\Main.java:8: <identifier> expected
    import JaCoP-3.0-RC1.*;
    2 errors
    E:\Documents and Settings\SSN\My Documents\NetBeansProjects\JavaApplication15\nbproject\build-impl.xml:413: The following error occurred while executing this line:
    E:\Documents and Settings\SSN\My Documents\NetBeansProjects\JavaApplication15\nbproject\build-impl.xml:199: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 0 seconds)

    where that dot should come in the first statement?i could not recognise..
    Are you sure? This action cannot be undone.
    Cancel
  • Reya

    MemberSep 15, 2010

    can anyone help me?
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberSep 15, 2010

    I don't have any idea about syntax and classes of JaCop library

    So i picked a program from net and it is working fine on my PC
    check whether the code that i given below is working fine or not

    if not then the problem is with class path

    import JaCoP.core.*; 
    import JaCoP.constraints.*; 
    import JaCoP.search.*; 
     
    public class Main { 
     
        static Main m = new Main (); 
     
        public static void main (String[] args) { 
            Store store = new Store();  // define FD store 
            int size = 4; 
            // define finite domain variables 
            IntVar[] v = new IntVar[size]; 
            for (int i=0; i<size; i++) 
                v[i] = new IntVar(store, "v"+i, 1, size); 
            // define constraints 
            store.impose( new XneqY(v[0], v[1]) ); 
            store.impose( new XneqY(v[0], v[2]) ); 
            store.impose( new XneqY(v[1], v[2]) ); 
            store.impose( new XneqY(v[1], v[3]) ); 
            store.impose( new XneqY(v[2], v[3]) ); 
     
            // search for a solution and print results 
            Search<IntVar> search = new DepthFirstSearch<IntVar>(); 
            SelectChoicePoint<IntVar> select = 
                new InputOrderSelect<IntVar>(store, v, 
                                             new IndomainMin<IntVar>()); 
            boolean result = search.labeling(store, select); 
     
            if ( result ) 
                System.out.println("Solution: " + v[0]+", "+v[1] +", "+ 
                                                  v[2] +", "+v[3]); 
            else 
                System.out.println("*** No"); 
        } 
    }            T
    Are you sure? This action cannot be undone.
    Cancel
  • Reya

    MemberSep 15, 2010

    working perfectly😀thank u so much dear😀
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register