Hi Bogdan, This is the second post you have made about using the C interface, and I think the first thing to say is that you should avoid using the C (or any of the other interfaces to other languages in ECLiPSe) interface to write ECLiPSe programs. That's not what the interfaces are designed for, i.e. it is not designed for making ECLiPSe a solver library for C (or C++). The best way to use the interface is to post goals with simple arguments from C, and then do most of the work of constructing the required data structures etc. in ECLiPSe, and pass back the required results, again in simple data structures, back to C. While it is possible to construct complex data structures in C, this is quite tedious, and easy to get wrong (including being able to construct incorrect data structures which could then lead to hard to debug errors). Your data structures may be relatively simple as ECLiPSe structures, but they are already quite complex, and you obviously are having problems with them. So the best suggestion I can make is: don't do this in C. As for your specific problem: you are posting the bb_options as an atom, and this is giving you an type error because bb_options should not be an atom. This is in actaully a good illustration of why you should not write ECLiPSe progrsm in C: The bb_options{...} is a named structure, a short-hand for a bb_options structure, which is expanded by the parser, and is designed to hide implementation details like what the exact size of bb_options is, and what the various arguments of the structure is used for. However, if you are constructing the goal from C, then you need to construct the "raw" structure, i.e. do the work of the parser in this case, that is, you need to construct the raw bb_options data structure, and in your case, put the strategy option you are using in the correct argument position. You can post a goal that does get parsed from C, by posting the goal as a string (ec_post_string()). However, in this case, you don't have direct access to the arguments in the goal, and in addition, you need to worry about the mostly quite subtle differences between string syntax in C and ECLiPSe, especially if you have a complicated goal (again, my suggestion is to avoid posting complicate goals). So in summary, write your ECLiPSe program in C, and keep the interface to C simple -- don't try to write the ECLiPSe program in C. If you must use C to write your constraint program, then I think ECLiPSe is not the tool you want, and you would be better off using some C (or C++) library that is designed for this. Cheers, Kish On 24/11/2011 17:36, Bogdan Tanasa wrote: > Hi, > > > > I am trying to call bb_min from C. > > I am doing something like this: > > > > search = ec_term(ec_did("search", 6), > > varList, > > ec_long(0), > > ec_atom(ec_did("most_constrained", 0)), > > ec_atom(ec_did("indomain", 0)), > > ec_atom(ec_did("complete", 0)), > > ec_nil() > > ); > > > > bb_min = ec_term(ec_did("bb_min", 3), > > search, > > objFunc, > > ec_atom(ec_did("bb_options{strategy:continue}", > 0))); > > ec_post_goal(ec_term(ec_did("writeln", 1), bb_min)); > > ec_post_goal(bb_min); > > > > I get the following error from CLP: > > > > type error in > > bb_min( > > search([_49506{[0, 1]}, _49524{[0, 1]}, _49542{[0, 1]}, _49560{[0, 1]}], 0, > most_constrained, indomain, complete, []), 1.0 * _49506 + 1.0 * _49524 + > 1.0 * _49542 + 1.0 * _49560, > > 'bb_options{strategy:continue}') in module eclipse > > > > The problem is passing the bb_options arguments. > > Can you please tell me how to fix it? > > > > Bogdan. > > > > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure > contains a definitive record of customers, application performance, > security threats, fraudulent activity, and more. Splunk takes this > data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-novd2d > > > > _______________________________________________ > ECLiPSe-CLP-Users mailing list > ECLiPSe-CLP-Users_at_lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users -- 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 Fri Nov 25 2011 - 19:03:45 CET
This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET