Re: [eclipse-clp-users] Q: Linear Programming with Disjunction constraints

From: Kim Lai <kim73327_at_gmail.com>
Date: Fri, 25 Apr 2008 20:58:16 +0800
On 4/25/08, Kish Shen <kisshen_at_cisco.com> wrote:
>
> Kim Lai wrote:
>
>> hi, your reply is a great help for me. thanks.
>> I use lib(eplex) to reformulate my problem as follow. and it really got a
>> solution.
>> But after I port the following code to C++. I'm getting trouble with ""How
>> to extract the variables result"".
>> A result like this "A2{0.0 .. 1.7976931348623157e+308 @
>> 1.1999999992549422}"
>> I'd like to extract A2=1.199 = 1.2
>> But it's not even a string...
>> in C++: I usually use "EC_word(Vars[i]).is_double(&d) == EC_succeed"
>> to get a double or long int .....And this didn't work..
>> ------------eclipse code------------------------
>>
>
> Your specific problem is that when a problem is solved by eplex, the
> problem variables are not instantiated. This allows you to modify the
> problem and resolve it. eplex_var_get/3 allows you to extract the solution
> value from the variable, e.g. for the variable A2 above,
>
> ....
> eplex_var_get(A2, solution, A2Sol),
>
>
> will instantiate A2Sol to the solution value of A2
>
> So you should exract the solution values, and pass these to C++.
>
> A more general point: I am not quite sure what you mean exactly by `porting
> to C++' - you seem to want to pass solution values from a ECLiPSe program to
> C++. This is probably the best way to use ECLiPSe as a constraint solver
> when you are using ECLiPSe with other languages -- but I would not call this
> `porting', but interfacing.
>
> Cheers,
>
> Kish
>

hi, I'm trying to use "eplex_var_get" in C++ and get trouble with the
EC_word's type.
In eclipse , everything works fine.
----------------------
Vars = [A1,A2]
eplex_var_get( A1, solution, A1 ), eplex_var_get( A2, solution, A2 ).
-------------------------
But after I put this in C++, I can't figure out what is the exact type of
this EC_word.
It should be a double. But .is_double(&d) doesn't work.
-------like this one--------------
EC_refs Vars(2); double d;
for( int i=0; i<2; i++ ) {
     post_goal( term( EC_functor( "eplex_var_get", 3), Vars[i],
EC_atom("solution"), Vars[i] ));
*     if( EC_word(Vars[i]).is_double(&d) == EC_succeed ) {*
            cout<< "Edge-"<< i<< "="<< d <<endl;
       }
}
------------------------------------------------------

thanks.

-- 
....Best Regards
                      by Kim Lai, 賴廣甫
Welcome to visit http://kimklai.blogspot.com
Received on Fri Apr 25 2008 - 05:58:21 CEST

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