Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.1K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

1/0 error when using NMaximize[]

Posted 2 years ago

(working code below)

I'm using NMaximize[] to solve an optimization problem comprising several projects with different costs. I have several constraints. When I solve for my variables as Elements in Reals I obtain a solution. When I change the domain to Integers (between 0 and 1) I get the following errors (mainly I get a 1/0 division error). Ideas? I'm not sure how to set starting conditions, etc., so I really don't know how to troubleshoot this.

Power::infy: Infinite expression 1/0 encountered

projCosts = {{40, 10, 20, 20, 0}, {65, 36, 30, 25, 30}, {6, 8, 10, 0, 
   0}, {20, 10, 20, 20, 0}}; yearlyFunds = {120, 40, 40, 55, 
  60}; totalPossibleFunds = {90, 65 + 36 + 30 + 25 + 30, 6 + 8 + 10, 
  20 + 10 + 20 + 20};

projScore = {.741, .845, .353, .457};

NMaximize[{projScore . {a, b, c, 
    d}, (projCosts[[#]][[1]] & /@ Range[Length[projScore]] . {a, b, c,
        d}) <= yearlyFunds[[1]] && (projCosts[[#]][[2]] & /@ 
       Range[Length[projScore]] . {a, b, c, d}) <= 
    yearlyFunds[[2]] && (projCosts[[#]][[3]] & /@ 
       Range[Length[projScore]] . {a, b, c, d}) <= 
    yearlyFunds[[3]] && (projCosts[[#]][[4]] & /@ 
       Range[Length[projScore]] . {a, b, c, d}) <= yearlyFunds[[4]] &&
    0 <= a <= 1 && 0 <= b <= 1 && 0 <= c <= 1 && 
   0 <= d <= 
    1 && ((totalPossibleFunds[[1]]*a + 
        totalPossibleFunds[[3]]*c)/(totalPossibleFunds[[1]]*a + 
        totalPossibleFunds[[3]]*c + totalPossibleFunds[[2]]*b + 
        totalPossibleFunds[[4]]*d)) <= 4/10}, {a, b, c, d} \[Element] 
  Integers]
POSTED BY: Michael Boehm
4 Replies
Posted 2 years ago
POSTED BY: Michael Boehm
Posted 2 years ago

well, i included a constraint that a+b+c+d>0

and now i get the following error:

NMaximize::nnum: The function value Indeterminate is not a number at {a,b,c,d} = {0.106664,0.321896,0.053649,0.0900987}.

POSTED BY: Michael Boehm
Posted 2 years ago

ChatGPT is saying NMaximize[] isn't designed for Integers, just continuous variables. So which optimization works for Integers?

POSTED BY: Michael Boehm
Posted 2 years ago

thanks.

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