TransWikia.com

Minimization over Booles

Mathematica Asked on November 20, 2020

I would like to set my domain of NMinimize so that my variables take values in {1,0}. I know I can use Booleans in FindInstance, but how can I define this in NMinimize to avoid writing it in the conditions? Here’s the shape of my code

n=10;v={1,2,3,4,1,5,1,4,6,1};
xi = Array[x, n];
NMinimize[{Total[v xi],
    AllTrue[xi, (# == 0 || # == 1) &]
  }, xi]

This is a strange example. My v and n will be bigger and I have more conditions, so I’m looking for ways of optimising the minimisation.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP