Skip to main content
whoopsiedaisy
Source Link
kirma
  • 19.1k
  • 1
  • 55
  • 95

VectorLessEqual is your friend, Element on lists works too:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-(0.80 R1 + 0.75 R2 + 0.56 R3 + 0.32 R4 + 
     0.25 R5 + 0.86 R6 + 0.93 R7),
  {0 <= Budget <= 500,
   VectorLessEqual[{0, Rs, 1}]},
   Element[Rs, Integers]]]Integers]},
  Rs]]

(* {R1 -> 1, R2 -> 1, R3 -> 0, R4 -> 1, R5 -> 1, R6 -> 1, R7 -> 0} *)

I'd probably write the constants with dot products, though:

With[{Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-({0.80 R1 +, 0.75 R2 +, 0.56 R3 +, 0.32 R4 + 
    , 0.25 R5 +, 0.86 R6 +, 0.93} R7). Rs,
  {0 <= Budget{30, 150, 300, 25, 85, 95, 435} . Rs <= 500,
   VectorLessEqual[{0, Rs, 1}], 
   Element[Rs, Integers]},
  Rs]]

VectorLessEqual is your friend, Element on lists works too:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-(0.80 R1 + 0.75 R2 + 0.56 R3 + 0.32 R4 + 
     0.25 R5 + 0.86 R6 + 0.93 R7),
  {0 <= Budget <= 500, VectorLessEqual[{0, Rs, 1}]},
  Element[Rs, Integers]]]

(* {R1 -> 1, R2 -> 1, R3 -> 0, R4 -> 1, R5 -> 1, R6 -> 1, R7 -> 0} *)

I'd probably write the constants with dot products, though:

With[{Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-(0.80 R1 + 0.75 R2 + 0.56 R3 + 0.32 R4 + 
     0.25 R5 + 0.86 R6 + 0.93 R7),
  {0 <= Budget <= 500, VectorLessEqual[{0, Rs, 1}], 
   Element[Rs, Integers]},
  Rs]]

VectorLessEqual is your friend, Element on lists works too:

With[{Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-(0.80 R1 + 0.75 R2 + 0.56 R3 + 0.32 R4 + 
     0.25 R5 + 0.86 R6 + 0.93 R7),
  {0 <= Budget <= 500,
   VectorLessEqual[{0, Rs, 1}],
   Element[Rs, Integers]},
  Rs]]

(* {R1 -> 1, R2 -> 1, R3 -> 0, R4 -> 1, R5 -> 1, R6 -> 1, R7 -> 0} *)

I'd probably write the constants with dot products, though:

With[{Rs = {R1, R2, R3, R4, R5, R6, R7}},
 LinearOptimization[-{0.80, 0.75, 0.56, 0.32, 0.25, 0.86, 0.93} . Rs,
  {0 <= {30, 150, 300, 25, 85, 95, 435} . Rs <= 500,
   VectorLessEqual[{0, Rs, 1}],
   Element[Rs, Integers]},
  Rs]]
added 66 characters in body
Source Link
kirma
  • 19.1k
  • 1
  • 55
  • 95

VectorLessEqual is your friend, Element on lists works too:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-(0.80 R1 + 0.75 R2 + 0.56 R3 + 0.32 R4 + 
     0.25 R5 + 0.86 R6 + 0.93 R7),
  {0 <= Budget <= 500, VectorLessEqual[{0, Rs, 1}]},
  Element[Rs, Integers]]]

(* {R1 -> 1, R2 -> 1, R3 -> 0, R4 -> 1, R5 -> 1, R6 -> 1, R7 -> 0} *)

I'd probably write the constants with dot products, though:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7}},
 LinearOptimization[
 Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-{(0.80, R1 + 0.75, R2 + 0.56, R3 + 0.32, R4 + 
     0.25, R5 + 0.86, R6 + 0.93} . RsR7),
  {0 <= {30, 150, 300, 25, 85, 95, 435} . RsBudget <= 500, 
   VectorLessEqual[{0, Rs, 1}]}, 
   Element[Rs, Integers]]]Integers]},
  Rs]]

VectorLessEqual is your friend, Element on lists works too:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-(0.80 R1 + 0.75 R2 + 0.56 R3 + 0.32 R4 + 
     0.25 R5 + 0.86 R6 + 0.93 R7),
  {0 <= Budget <= 500, VectorLessEqual[{0, Rs, 1}]},
  Element[Rs, Integers]]]

(* {R1 -> 1, R2 -> 1, R3 -> 0, R4 -> 1, R5 -> 1, R6 -> 1, R7 -> 0} *)

I'd probably write the constants with dot products, though:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7}},
 LinearOptimization[
  -{0.80, 0.75, 0.56, 0.32, 0.25, 0.86, 0.93} . Rs,
  {0 <= {30, 150, 300, 25, 85, 95, 435} . Rs <= 500, 
   VectorLessEqual[{0, Rs, 1}]},
  Element[Rs, Integers]]]

VectorLessEqual is your friend, Element on lists works too:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-(0.80 R1 + 0.75 R2 + 0.56 R3 + 0.32 R4 + 
     0.25 R5 + 0.86 R6 + 0.93 R7),
  {0 <= Budget <= 500, VectorLessEqual[{0, Rs, 1}]},
  Element[Rs, Integers]]]

(* {R1 -> 1, R2 -> 1, R3 -> 0, R4 -> 1, R5 -> 1, R6 -> 1, R7 -> 0} *)

I'd probably write the constants with dot products, though:

With[{Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-(0.80 R1 + 0.75 R2 + 0.56 R3 + 0.32 R4 + 
     0.25 R5 + 0.86 R6 + 0.93 R7),
  {0 <= Budget <= 500, VectorLessEqual[{0, Rs, 1}], 
   Element[Rs, Integers]},
  Rs]]
deleted 1 character in body
Source Link
kirma
  • 19.1k
  • 1
  • 55
  • 95

VectorLessEqual is your friend, Element on lists works too:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-(0.80 R1 + 0.75 R2 + 0.56 R3 + 0.32 R4 + 
     0.25 R5 + 0.86 R6 + 0.93 R7),
  {0 <= Budget <= 500, VectorLessEqual[{0, Rs, 1}]},
  Element[Rs, Integers]]]

(* {R1 -> 1, R2 -> 1, R3 -> 0, R4 -> 1, R5 -> 1, R6 -> 1, R7 -> 0} *)

I'd probably write the constants with dot products, though:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7}},
 LinearOptimization[
  -{0.80, 0.75, 0.56, 0.32, 0.25, 0.86, 0.93 } . Rs,
  {0 <= {30, 150, 300, 25, 85, 95, 435} . Rs <= 500, 
   VectorLessEqual[{0, Rs, 1}]},
  Element[Rs, Integers]]]

VectorLessEqual is your friend, Element on lists works too:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-(0.80 R1 + 0.75 R2 + 0.56 R3 + 0.32 R4 + 
     0.25 R5 + 0.86 R6 + 0.93 R7),
  {0 <= Budget <= 500, VectorLessEqual[{0, Rs, 1}]},
  Element[Rs, Integers]]]

(* {R1 -> 1, R2 -> 1, R3 -> 0, R4 -> 1, R5 -> 1, R6 -> 1, R7 -> 0} *)

I'd probably write the constants with dot products, though:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7}},
 LinearOptimization[
  -{0.80, 0.75, 0.56, 0.32, 0.25, 0.86, 0.93 } . Rs,
  {0 <= {30, 150, 300, 25, 85, 95, 435} . Rs <= 500, 
   VectorLessEqual[{0, Rs, 1}]},
  Element[Rs, Integers]]]

VectorLessEqual is your friend, Element on lists works too:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7},
  Budget = 30 R1 + 150 R2 + 300 R3 + 25 R4 + 85 R5 + 95 R6 + 435 R7},
 LinearOptimization[-(0.80 R1 + 0.75 R2 + 0.56 R3 + 0.32 R4 + 
     0.25 R5 + 0.86 R6 + 0.93 R7),
  {0 <= Budget <= 500, VectorLessEqual[{0, Rs, 1}]},
  Element[Rs, Integers]]]

(* {R1 -> 1, R2 -> 1, R3 -> 0, R4 -> 1, R5 -> 1, R6 -> 1, R7 -> 0} *)

I'd probably write the constants with dot products, though:

With[
 {Rs = {R1, R2, R3, R4, R5, R6, R7}},
 LinearOptimization[
  -{0.80, 0.75, 0.56, 0.32, 0.25, 0.86, 0.93} . Rs,
  {0 <= {30, 150, 300, 25, 85, 95, 435} . Rs <= 500, 
   VectorLessEqual[{0, Rs, 1}]},
  Element[Rs, Integers]]]
added 323 characters in body
Source Link
kirma
  • 19.1k
  • 1
  • 55
  • 95
Loading
Source Link
kirma
  • 19.1k
  • 1
  • 55
  • 95
Loading