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

From: Christos Orovas <c_orovas_at_...102...>
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,


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

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

using namespace std;

int main(){

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


 ec_ref toC;
 toC = ec_ref_create_newvar();


 number = 35;
 fd = ec_stream_nr("my_out_queue");
 n  = ec_queue_read((int) fd, buf, 1024);
 buf[n] = 0;
 printf("eclipse returned: %s\n", buf);


:- 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],
    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 !!"),
    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_at_...107...> έγραψε:
Από: Soheil Samii <sohsa@...109...7...>
Θέμα: [eclipse-clp-users] Scheduling using the C++ interface to ECLiPSe
Ημερομηνία: Τρίτη, 29 Απρίλιος 2008, 18:05


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
with the C++ interface? Other comments are appreciated.


This email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save
Use priority code J8TL2D2.;198757673;13503038;p?
ECLiPSe-CLP-Users mailing list

Χρησιμοποιείτε Yahoo!
Βαρεθήκατε τα ενοχλητικά μηνύ ματα (spam); Το Yahoo! Mail διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων
Received on Tue Apr 29 2008 - 13:56:30 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 22 2019 - 09:15:17 CEST