[gecode-users] Fwd: Multi-objective Model with Searchcombinators in Gecode
Guido Tack
tack at gecode.org
Fri Mar 14 22:03:18 CET 2014
I can't test it right now, but it should be like this:
portfolio([
%% minimise => obj1 < lv("best1")
%% maximize => obj1 > lv("best1")
and(
post(obj1 < lv("best1"),
and(s,assign(best1,obj1))
),
prune
),
%% minimise => obj2 < lv("best2")
%% maximize => obj2 > lv("best2")
and(
post(obj1=lv("best1"),
post(obj2 < lv("best2"),
and(s,assign(best2,obj2))
)
),
prune
),
%% minimise => obj3 < lv("best3")
%% maximize => obj3 > lv("best3")
post(obj1=lv("best1"),
post(obj2=lv("best2"),
post(obj3 < lv("best3"),
and(s,assign(best3,obj3))
)
)
)
])
Cheers,
Guido
On 13 Mar 2014, at 6:53 am, Mohamed Rezgui <kyo.alone at gmail.com> wrote:
> ---------- Forwarded message ----------
> From: Mohamed Rezgui <kyo.alone at gmail.com>
> Date: 2014-03-12 20:53 GMT+01:00
> Subject: Re: [gecode-users] Multi-objective Model with
> Searchcombinators in Gecode
> To: Guido Tack <tack at gecode.org>
>
>
> Hi,
>
> yes the two objective version works very well.
>
> But when I did not found the good syntax for 3 and several objectives :S
> Can you send me the right syntax please ?
>
> % Variables
> var 0..10: obj1;
> var 1..10: obj2;
> var 2..10: obj3;
>
> This following code give me these solutions :
> {10, 1, 9}
> {10, 1, 8}
> {10, 1, 7}
> {10, 1, 6}
> {10, 1, 5}
> {10, 1, 4}
> {10, 1, 3}
> {10, 1, 2}
>
> the first objective is not minimized :S
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%
> portfolio([
>
> and(
> and(
> %% minimise => obj2 < lv("best2")
> %% maximize => obj2 > lv("best2")
> post(obj1=lv("best1"),
> post(obj2 < lv("best2"), and(s,assign(best2,obj2)))),
> prune
> ),
>
> %% minimise => obj1 < lv("best1")
> %% maximize => obj1 > lv("best1")
> and(
> post(obj1 < lv("best1"), and(s,assign(best1,obj1))),
> prune
> )
> ),
>
>
> %% minimise => obj3 < lv("best3")
> %% maximize => obj3 > lv("best3")
> post(obj2=lv("best2"),
> post(obj3 < lv("best3"), and(s,assign(best3,obj3))))
>
> ])
>
> with trace_sol, I have this bug (gecode 4.2.1, flatzinc 1.6,
> searchcombinators 0.9.3 modified API for gecode 4.2.1):
> trace_sol("*" ++ "\n", ...) //does not work
> Error: Unknown character in line no. 4
> Error: Unknown character in line no. 4
> Error: syntax error, unexpected FZ_ID, expecting ')' or ',' in line no. 5
>
> Best Regards,
> Mohammed REZGUI
>
> 2014-03-12 20:35 GMT+01:00 Guido Tack <tack at gecode.org>:
>> Hi,
>>
>> you'd have to be a bit more specific than "does not work". Did the two objective version work? In your code the second stage does not do a "prune" when it's done like the first stage, so it will actually never switch to the third stage.
>>
>> Output is rather limited at the moment, the code you're using was written as a prototype for a paper, not a production quality system.
>>
>> Cheers,
>> Guido
>>
>> On 13 Mar 2014, at 6:21 am, Mohamed Rezgui <kyo.alone at gmail.com> wrote:
>>
>>> Dear Guido,
>>>
>>> I compile successfully searchcombinators with gecode 4.2.1 (I change
>>> with the appropriate API).
>>> I would like to know how can I set 3 ou several objectives (on
>>> lexicographic multi-objective) please ?
>>> I test with different approaches and it does not work.
>>>
>>> Other question how can I print pretty like output with trace_solution
>>> I found a bug with concatenation "*" ++ "\n" (it does not work).
>>>
>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>> include "globals.mzn";
>>> include "searchcombinators.mzn";
>>>
>>> annotation lexicoMinimize3obj(var int: obj1, var int: obj2, var int:
>>> obj3, ann: s) =
>>> let {
>>> %% minimise => svar int: best1 = ub(obj1)
>>> %% maximize => svar int: best1 = lb(obj1)
>>> svar int: best1 = ub(obj1),
>>>
>>> %% minimise => svar int: best2 = ub(obj3)
>>> %% maximize => svar int: best2 = lb(obj3)
>>> svar int: best2 = ub(obj2),
>>>
>>> %% minimise => svar int: best2 = ub(obj3)
>>> %% maximize => svar int: best2 = lb(obj3)
>>> svar int: best3 = ub(obj3)
>>> }
>>> in (
>>>
>>>
>>> portfolio([
>>>
>>> %% minimise => obj1 < lv("best1")
>>> %% maximize => obj1 > lv("best1")
>>> and(
>>> post(obj1 < lv("best1"), and(s,assign(best1,obj1))),
>>> prune
>>> ),
>>>
>>> %% minimise => obj2 < lv("best2")
>>> %% maximize => obj2 > lv("best2")
>>> post(obj1=lv("best1"),
>>> post(obj2 < lv("best2"), and(s,assign(best2,obj2)))),
>>>
>>>
>>> %% minimise => obj3 < lv("best3")
>>> %% maximize => obj3 > lv("best3")
>>> post(obj2=lv("best2"),
>>> post(obj3 < lv("best3"), and(s,assign(best3,obj3))))
>>>
>>> ])
>>>
>>> );
>>>
>>> % Variables
>>> var 0..10: obj1;
>>> var 1..10: obj2;
>>> var 2..10: obj3;
>>>
>>> %% call
>>> solve
>>> :: print([obj1, obj2, obj3], lexicoMinimize3obj(obj1, obj2, obj3,
>>> int_search([obj1, obj3, obj2], input_order, assign_ub)
>>> ))
>>> satisfy;
>>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>>
>>>
>>> Best Regards,
>>> Mohammed REZGUI
>>
>
>
>
> --
> Cordialement,
> Mohamed REZGUI
>
>
> --
> Cordialement,
> Mohamed REZGUI
>
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
More information about the users
mailing list