Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.9K Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

Errors in defining variables (binary) and equalitites

Posted 7 years ago
POSTED BY: Wael Al Hajailan
3 Replies
Posted 7 years ago

Try

npm1 = z0 1 + z1 2 + z2 3 + z3 4;
NMinimize[{npm1,z0+z1+z2+z3==1&&0<=z0<=1&&0<=z1<=1&&0<=z2<=1&&0<=z3<=1},{z0,z1,z2,z3}]

If you want to constrain your variables to be 0 or 1 then you should look at

Element[z0,Integers]&&0<=z0<=1

Otherwise your variables can have any value between 0 and 1

POSTED BY: Bill Nelson
Posted 7 years ago

This

Set::write: Tag Plus in a0+b0 is Protected.

error is probably because of using = instead of == in

z0+z1+z2+z3==1
POSTED BY: Bill Nelson

Should I use "&&" between defining the constraints? I have already defined them as integers:

{a0, a1, a2, a3, b0, b1, b2, b3, z0, z1, z2, z3} \[Element] Integers}

So, why it is not a valid variable ? and protected? Thanks,

POSTED BY: Wael Al Hajailan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard