Re: [eclipse-clp-users] API for c++ nolinear constraints

From: Kish Shen <kisshen_at_...5...>
Date: Wed, 26 Aug 2009 14:27:44 +0100
liu.yu.senior.china wrote:

> This is a very good suggestion. But how to do this? Do you mean besides the c++ code, I should code 
> e a file containing eclipse code and use the c++ code to pass the parameters and call the eclipse 
> file?
> again, do you have examples?

There are various ways to pass the parameters from C++ to ECLiPSe.
You can write your parameters into a file that you read in your ECLiPSe 
program (which you write, and not generate from C++ as you suggest). 
This is how a lot of ECLiPSe program works -- you read in data from a 
file, which is then used to generate your constraints -- this allows 
your program to deal with different problem instances.

Some of the examples show how a program can read data and generate the 
constraints from them -- rostering (in the planning and scheduling 
section of the ECLiPSe code samples page) is a good example. One 
difference from real applications is that to keep things simple, the 
data are in the same file as the program. Also, the data is in ECLiPSe 
format (as Prolog facts). Neither of these are requirements -- the data 
can be in non-Prolog syntax and in different files from your program.
You just need to use the I/O facilities of ECLiPSe (as described in the 
manual) to read the data.

An alternative to passing the parameters via files is to pass the 
parameters in a call to an ECLiPSe goal from C++, as one of the 
arguments. You can then generate the constraints from the argument in 
your ECLiPSe program (which implements the goal that you call from C++).

ECLiPSe is a general programming language, and there are many different 
ways to solve problems. It is therefore impossible to cover all possible 
instances with examples. The purpose of the examples is to show how 
programming can be done in ECLiPSe, and not really intended as templates 
that you can copy into your own code and use directly.

> The link and the sendmore example are too simple and general to help anything. Any complicated
> examples with nonlinear constraints using C++ API? Anyway, I appreciate all your help.
I am not sure why the sendmore example is too general -- if you mean you 
cannot just copy it and use it directly, you are probably right. As 
already mentioned, this is not the intention of the examples.
The example does show you how to construct nested terms, and also how 
you can construct a constraint expression with many variables. This 
should give you what you need to construct the constraints you 
mentioned. I do not see what is the significant differences between 
linear and nonlinear constraints -- you can write both as expressions in 
ECLiPSe (and thus in the C++ code you would write).



This e-mail may contain confidential and privileged material for the
sole use of the intended recipient. Any review, use, distribution or
disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact
the sender by reply e-mail and delete all copies of this message.
Cisco Systems Limited (Company Number: 02558939), is registered in
England and Wales with its registered office at 1 Callaghan Square,
Cardiff, South Glamorgan CF10 5BT.
Received on Wed Aug 26 2009 - 13:27:57 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 25 2019 - 06:15:50 CEST