0

I've tried to replicate the below code for my own optimization problem.

However, I only get one loop.

When printing the objectives below without calling the method value(), each objective is True. For mine they are False.

How do I interpret these results?

Many thanks.

x, y = Ints('x y')
opt = Optimize()
opt.set(priority='pareto')
opt.add(x + y == 10, x >= 0, y >= 0)
mx = opt.maximize(x)
my = opt.maximize(y)
while opt.check() == sat:
    print (mx.value(), my.value())
tomp
  • 55
  • 7
  • Make sure the check returns sat. If it doesn’t, that’d mean the objectives weren’t satisfied, ie your system is unsatisfiable. You should post the exact code you’re running. – alias Sep 16 '22 at 01:36

1 Answers1

1

It’s hard to decipher what you mean. By “I only get one loop” I assume you mean you get the values printed only once and that’s it. That’s perfectly fine, it simply means the Pareto front only has one element.

To get a better analysis, you’ll have to post the actual code (as simplified as you can). Without seeing exactly what you’re doing it’s impossible to opine further.

alias
  • 28,120
  • 2
  • 23
  • 40
  • Thank you. I'm unable to post my code unfortunately, but the setting of objectives and running of the optimizer is exactly as the example posted. The one question I still have, is what does it mean if the (the OptimizeObjective objects) are True or False? In response to your other comment, check does return sat. – tomp Sep 16 '22 at 07:12
  • 1
    If the solver is sat, all objectives must be True. Otherwise it’s a bug. – alias Sep 16 '22 at 14:12
  • 1
    I should’ve said “all constraints” must be True. Objectives are what you’re optimizing, of course. I hope that was clear. – alias Sep 16 '22 at 14:57
  • All constraints are satisfied, and check returns sat, but the objectives are being returned as False. I'm unsure why they're being returned as False. If you can help me understand, I'd love to know. Many thanks. – tomp Sep 16 '22 at 15:02
  • Objectives are usually numeric values. So, I’m not sure what you mean they are “False”. – alias Sep 16 '22 at 15:11
  • In the code provided, if you use the method .value() on an OptimizeObjective, it produces a numeric value. However, if you don't call the method and print the object its self, it appears to return either True or False. In the example provided, the object is printed as True. In my example, the objective is printed as False. – tomp Sep 16 '22 at 15:52
  • 1
    I wouldn’t attach any meaning to that result. Probably an artifact of the loosely typed nature of the Python bindings. – alias Sep 16 '22 at 15:54