Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.7K Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Use a proper optimization function for a profit model?

Posted 8 years ago

Hello,

First time user of Mathematica and I'm really enjoying it! I've created a profit maximization model for a manufacturing firm with many different variables. I want to figure out a way to tell my model to maximize profit subject to a few constraints by changing only a select subset of variables. What would be the best function for doing that?

I've tried searching online for an answer but it's not immediately clear what function would allow me to specify constraints as well as the specific variables I want the optimizer to change in order to optimize. I've attached my model just in case - apologies in advance for the way it's constructed....it's my first one! ha

Thanks, Scott

Attachments:
POSTED BY: Scott T
6 Replies

Scott,

There is no need to "introduce" variables -- just use them. All the variable assignments you do are unnecessary and can lead to problems.

You seem to be very confused about when to use = and when to use ==. The single equal is an assignment -- think of it as a shortcut -- when you use it, Mathematica will immediately replace the left hand name with the right side.

The == is used to construct equations -- you only use this if you need an equation -- most of your model does not need equations and you only need them for the constraints in Minimize.

This is the cause of your errors. When you do

rawResourceAllocation = 
  rawAllocation == {{r1p1, r2p1, r3p1}, {r1p2, r2p2, r3p2}, {r1p3, 
     r2p3, r3p3}};

you believe that you can take parts of rawAllocation -- you cannot! it is only a variable in an equation. If you want to take parts, you must do this:

rawAllocation = {{r1p1, r2p1, r3p1}, {r1p2, r2p2, r3p2}, {r1p3, 
     r2p3, r3p3}};

You repeat this mistake throughout your model. You really never need == in this application. In this type of problem you will ONLY use == if you have a constraint such as

variable == 50, or variable1 + variable2==50.

Otherwise you do not need it in your problem.

You are very close. Send me an email at neils at the domain in my profile. I can give you better suggestions that way.

Regards

POSTED BY: Neil Singer
Posted 8 years ago

Neil, thank you so much for all your help!

I managed to modify my original optimization problem thanks to the input you gave. One final issue I'm having appears to be when I try to reference my matrices. I've attached my model for reference (with the errors) but here is a sample:

rawPlant1 = 
  rawAllocationPlant1 == 
   rawAllocation[[1, 1]] + rawAllocation[[1, 2]] + 
    rawAllocation[[1, 3]];

Error message: Part::partd: Part specification rawAllocation[[1,1]] is longer than depth of object. Part::partd: Part specification rawAllocation[[1,2]] is longer than depth of object. Part::partd: Part specification rawAllocation[[1,3]] is longer than depth of object.

Also, apologies in advance for the extra variables (region1plant1 = r1p1, etc) but I could not figure out how to introduce the variables any other way (can you just insert them into an assignment without having used them before?).

Thanks again...

Attachments:
POSTED BY: Scott T

Scott,

It is strange, I got your posting as an email but it is not here on the site.

Your problem is solved as follows:

CostofPart1 = 1;
CostofPart2 = 2;
NumberofPart1 = x;
NumberofPart2 = y;
ExCosts = 
  ExampleCosts == ((CostofPart1*NumberofPart1) + (CostofPart2*
       NumberofPart2));
ExampleRevenue = ExampleRev;
prof = ExampleRevenue - ExampleCosts;

Now construct the constraints -- they must be one expression separated by && -- (Eqn1 AND Eqn2 AND ...)

constraintsA = 
  ExampleCosts >= 100 && ExampleRev <= 1000 && 
   20 <= NumberofPart1 <= 80 && 20 <= NumberofPart2 <= 80;

Solve the problem with:

Maximize[{prof, constraintsA && ExCosts}, {ExampleCosts, ExampleRev, 
  NumberofPart1, NumberofPart2}]

to get:

{900, {ExampleCosts -> 100, ExampleRev -> 1000, x -> 20, y -> 40}}

Note that I used ";" to end lines to suppress printing. You are mixing up equations and variables and assignments. you solve for variables -- they do not have to be x and y but they must be consistently used. Also, you really should not have expressions like ExampleRevenue = ExampleRev Adding extra variables only confuses things. Just use the minimal number -- I left some in your example but I would avoid the confusion.

The answer of 900 is correct -- the profit is ExampleRev - ExampleCosts = (1000 - 100) = 900. The cost of 100 comes from the 20 units of x at 1 and 40 units of y at 2 (80 +20 = 100)

anything else would not maximize profit and meet the constraints.

Lastly it is bad form to start variables with Capital letters -- Mathematica internal symbols start with Cap letters -- yours should not.

I hope this helps

POSTED BY: Neil Singer

Scott,

I am not sure I understand your question. I assume you want to maximize profit subject to constraints?

POSTED BY: Neil Singer
Posted 8 years ago

Use a proper optimization function for a profit model?

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