Re: [eclipse-clp-users] Scheduling using the C++ interface to ECLiPSe

From: Christos Orovas <c_orovas_at_yahoo.co.uk>
Date: Tue, 29 Apr 2008 20:56:14 +0000 (GMT)
Hi there,

I recently had a similar task to do. After a help from Joachem I managed to
finally handle things with C. Found it easier than the C++ interface and actually
I just needed a simple interfacing.

I am sending a sample C and eclipse code for the magic square.

I compiled it in .NET so if you use the same environment remember to use Release
version for the executable otherwise it keeps asking for some .dlls ..
And also the first directives in the .C are necessary if not in unix..

If someone has a similar thing in C++ I would like to see it as well..

Good luck,

Christos


===========================test.c===========================================================
/* If we're not using GNU C, elide __attribute__ */
#ifndef __GNUC__
#  define  __attribute__(x)  /*NOTHING*/
#endif

#include <iostream>
#include "eclipse.h"

using namespace std;

int main(){

 char    buf[1024];
 int    n;
 int    fd; // file descriptor
 int    number;

 ec_init();

 ec_ref toC;
 toC = ec_ref_create_newvar();

 ec_post_goal(ec_term(ec_did("compile",1),ec_string("cmagicsq")));

 number = 35;
 ec_post_goal(ec_term(ec_did("magicsq",2),ec_newvar(),ec_long(number)));
 
 ec_resume();
 
 fd = ec_stream_nr("my_out_queue");
 n  = ec_queue_read((int) fd, buf, 1024);
 buf[n] = 0;
 printf("eclipse returned: %s\n", buf);

 ec_cleanup();
}

=========================cmagicsq.ecl==============================================================
:- lib(ic).
:- lib(ic_global).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- set_stream(error,null).
:- set_stream(warning_output,null).
%:- set_stream(output,null).
%:- set_stream(log_output,null).
:- open(queue(""), write, my_out_queue). %% for output in memory-stream
%:- open(tmpfile, write, my_out_queue).  %% for output in file "tmpfile"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

magicsq( Digits, N) :-
        Digits = [A1,A2,A3,B1,B2,B3,C1,C2,C3],
        Digits :: [-20..20],
        ic_global:alldifferent(Digits),
       
    A1+A2+A3 #= N,
    B1+B2+B3 #= N,
    C1+C2+C3 #= N,
    A1+B1+C1 #= N,
    A2+B2+C2 #= N,
    A3+B3+C3 #= N,

        writeln("hi from here !!"),
        labeling(Digits),
   
    write(my_out_queue, Digits),     %% writing to output queue stream
    write(my_out_queue, N),
    flush(my_out_queue).                %% flushing the queue stream
   
==============================================================================









--- Στις Τρίτ., 29/04/08, ο/η Soheil Samii <sohsa@ida.liu.se> έγραψε:
Από: Soheil Samii <sohsa@ida.liu.se>
Θέμα: [eclipse-clp-users] Scheduling using the C++ interface to ECLiPSe
Προς: eclipse-clp-users@lists.sourceforge.net
Ημερομηνία: Τρίτη, 29 Απρίλιος 2008, 18:05

Hi!

I have a classical scheduling problem (with a nonlinear cost function) where
the task is to schedule a number of jobs with given resource demands
(execution times) on one or several processors (resources). The type of
constraints are precedence constraints and resource constraints. Due to
legacy constraints, I have to implement this in C++ using the C++ ECLiPSe
interface. I have set up the environment and I'm currently trying to
understand the C++ interface. There are some small examples in the ECLiPSe
installation, but many of them don't work.

Does anyone have any example code that solves a similar problem using
ECLiPSe
with the C++ interface? Other comments are appreciated.

Thanks,
/Soheil

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save
$100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
ECLiPSe-CLP-Users mailing list
ECLiPSe-CLP-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users


Χρησιμοποιείτε Yahoo!
Βαρεθήκατε τα ενοχλητικά μηνύ ματα (spam); Το Yahoo! Mail διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων
http://login.yahoo.com/config/mail?.intl=gr
Received on Tue Apr 29 2008 - 13:56:30 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET