0

I have a situation here which i am trying hard to solve, I have a dataset with 4 variables - a,b,c,d. I am trying to optimize the variables c and d to minimize the objective function 100*c + 50*d > 0. where 100 & 50 are my constants. 'b' has unique values for every 10 records in my data set.

The problem I have is that my constraints are for every subset of records in my dataset. So the granularity differs here. constraints are,

1. sum(c) for every unique 'b' should be less than a constant specified for that unique b 
2. sum(d) for every unique 'b' should be less than a constant specified for that unique b
3. c+d should be equal to a

c & d mentioned in the dataset are just initial values, i am trying to solve them. Any idea how to formulate this in R?

ds_user
  • 2,139
  • 4
  • 36
  • 71
  • I think there are two x and y's in your description: the first ones are data (columns in the data set) and the others are decision variables. That makes the question hard to parse (at least for me). In optimization models we make a clear distinction between decision variables (these quantities are changed by the solver) and constants or data (this is fixed). – Erwin Kalvelagen Aug 15 '16 at 12:19
  • How about a reproducible example? http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – renato vitolo Aug 15 '16 at 19:37
  • I am actually looking for an example to formulate this situation in R, then I can actually use it for my real work. – ds_user Aug 15 '16 at 19:44
  • To me, it is not clear where c1 and c2 come from. Are they part of the dataset? Also, as already mentioned by @ErwinKalvelagen, how can you solve for y and z when they are part of the dataset? – Karsten W. Aug 15 '16 at 19:59
  • Ok, y and z is just initial values in the dataset. I want to solve them. c1 and c2 are constants. Yes may be i can rewrite the question, then its easy to understand. – ds_user Aug 15 '16 at 20:02
  • Thanks for your comments. I have edited the question to answer the comments. @KarstenW.@ErwinKalvelagen – ds_user Aug 15 '16 at 20:09
  • I still don't get it. `c` and `d`seem like scalar variables (see objective: `min 100*c + 50*d`). But then you talk about `sum(c)`. That seems to indicate `c` is a vector (or matrix). – Erwin Kalvelagen Aug 15 '16 at 21:03
  • 1
    http://stackoverflow.com/questions/38937973/minimise-objective-function-using-r/38962980#38962980 This is the question I am talking about. Hope that will answer all your queries, don't try to use that script, it's not right, I am looking for approach to solve the problem, not someone to debug my code there. – ds_user Aug 15 '16 at 21:08

0 Answers0