Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have some logical relationships that I ultimately want to pass to NMaximize as constraints: {x => a, y => a, a => x || y}

NMaximize is picky about its input format though, so I'm feeding the expression into BooleanMinimize before, which produces something like: {!x || a, !y || a, ...}.

NMaximize can't handle unary negation, but accepts x! = 1. I looked at BooleanConvert, but most of the forms still use logical negation. What's the best way to deal with this?

share|improve this question
    
But !x is not the same as x != 1... consider what you get when x = 1 (or anything, for that matter) –  rm -rf Aug 25 '13 at 8:08
    
!1 = 0, !0 = 1, 1!=1 = 0, 0!=1 = 1 under the additional constraints {0 <= x <= 1, x e Integers} –  Neal Alexander Aug 25 '13 at 8:28
    
What you are asking is not clear. Please provide more contextual info about your problem. –  m_goldberg Aug 25 '13 at 17:36
    
constraints = {x ⇒ y||z} converted = constraints /. a_⇒b_ :> (a!= 1||b!=0) NMaximize[{x+y+z, converted}, {x,y}] –  Neal Alexander Aug 25 '13 at 18:47

1 Answer 1

up vote 1 down vote accepted

It's not clear to me what you seek, but just in case the plain answer happens to be it:

{! x || a, ! y || a} /. Not[n_] :> n != 1
{x != 1 || a, y != 1 || a}
share|improve this answer
3  
Not[]?? 4 characters more than the obvious one, ! n_ :> n != 1 ø_Ø? You need some sleep... –  rm -rf Aug 25 '13 at 16:47
    
@rm-rf LOL -- yes; yes, I do. –  Mr.Wizard Aug 25 '13 at 18:18
1  
Yea, this is pretty much what was needed - thanks. Replacing !x wasn't enough though. Even x in the positive form makes NMaximize cry. Doing constraints /. a_⇒b_ :> (a!= 1||b!=0) works fine though. –  Neal Alexander Aug 25 '13 at 18:57
    
@rm-rf Still haven't slept yet but I'm back to mangle some more answers. :o) –  Mr.Wizard Aug 26 '13 at 1:00
    
@Neal I'm glad it worked out for you. –  Mr.Wizard Aug 26 '13 at 1:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.