SCIP solver multiple objective functions with weights in Java

302 views
Skip to first unread message

JAIME VIEJO MARTINEZ

unread,
Mar 18, 2021, 11:38:27 AM3/18/21
to or-tools-discuss

Hello,

I'm new in constraint programming.
I'm trying to solve a problem that requires a multi objective function(o.f.) such as:
o.f.: obj1+ obj2 + ... + obj7
Each objective is multiplied by a weight (1000, 8, 1) and a parameter defined in arrays (d, um, m, cob, r, cost).

In the examples i've been learning from, it seems that when they add a coefficient it just adds it to the objective function.

In my case some values that I add are ignored and others ar not. I can't find why is this happening.

This is what I have:

ortools.JPG

In the example I'm using there is only one possibility and it's cost should be over 1000. But the results value is 40.01.
When i comment the 40 cost line the result value is 1000.01. It seems that it's only taking the last line of each for.

Any thoughts on what am I doing wrong?

Thanks in advance!

JAIME VIEJO MARTINEZ

unread,
Mar 23, 2021, 5:54:34 AM3/23/21
to or-tools-discuss
Any thoughts on what could be going on here?

Laurent Perron

unread,
Mar 23, 2021, 5:59:31 AM3/23/21
to or-tools-discuss
So, 

1) this is not constraint programming, but mixed integer programming.
2) without the full model, nobody can assess that there is only one solution.
3) The API you use is setCoefficient, not addCoefficient. Thus only the last setObjective on x[i][j] is kept.
Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/e0e8747a-1eda-4291-82ea-f5a1185b78c2n%40googlegroups.com.

JAIME VIEJO MARTINEZ

unread,
Mar 24, 2021, 12:01:36 PM3/24/21
to or-tools-discuss
Thank you very much.

I'll try to change the API so that the addCoefficient is available.

Thanks again!

Laurent Perron

unread,
Mar 24, 2021, 12:18:00 PM3/24/21
to or-tools-discuss
There is no AddCoefficient, for the exact reason mentionned above.
Just sum all coefficients before calling SetCoefficient.

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00


Erik Cervin Edin

unread,
Mar 24, 2021, 12:21:48 PM3/24/21
to or-tools...@googlegroups.com
i have no experience with this but I wonder if you're supposed to set the coefficient for the same variable multiple times like that

it doesn't strike me as odd that the result would only depend on the last set in such a case

--

Laurent Perron

unread,
Mar 24, 2021, 12:27:17 PM3/24/21
to or-tools-discuss
it is called Set, so by definition it overwrites the value.
There is not Add() because it is not O(1).

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00


JAIME VIEJO MARTINEZ

unread,
Mar 25, 2021, 12:18:11 PM3/25/21
to or-tools-discuss
Thank you very much for all the responses.

This is what I came up with after following your guidance, pretty simple after all...

ortools_good.JPG
I'll have to make further validations in order to make sure it works just fine but I think it'll do :)

Thank you again.
Jaime
Reply all
Reply to author
Forward
0 new messages