2
$\begingroup$

I want to run a rather demanding check of feasibility.

I have 3565 non-negativity constraints for my variables, and one that makes them sum to a certain budget they shall not surpass. I also have one inequality constraint that calculates whether or not, for a given set of values of the variables, a given constant is smaller or larger than the Gini coefficient for the current data.

The expression looks like this:

GWSUB[y_, ES_, t_, w_, k_] := Module[{yt, ytw, Gini},
    yt = (y + t) / ES;
    ytw = (w*(y + t)) / ES;
    Gini = -k*(2*(Plus @@ w)*(Plus @@ ytw)) + 
             Sum[ (w[[j]]*(Plus @@ Abs[ytw - yt[[j]]*w]), {j, 1, Length[y]}
  ]

Here are the meanings of the symbols I used:

  • The vector of variables is $t$.
  • $y$ is a vector of incomes.
  • $w$ is a vector of weights.
  • ES is a separate vector of weights.
  • $k$ defines the candidate value for the Gini coefficient and is a scalar.

The vectors are all of length 3565.

I then tried to run the FindMinimum command. Here T is the vector of variables t[i]. TC are the non-negativity constraints on the t[i]. B is the budget (a scalar).

FindMinimum[
  {
   0*(Plus @@ T),
   GWSUB[Y, ES, T, W, 0.3294] <= 0, 
   Sequence[TC], (Plus @@ T) == B
  },
  T, 
  Method -> "InteriorPoint", WorkingPrecision -> 7, MaxIterations -> 500
]

I get an error of this form:

FindMinimum::cnpcons: Could not process the constraints ...

and then it refers to the GWSUB expression.

Does this mean that I cannot run the computation with the current machine? Is there a way to simplify the expression, so that Mathematica will process it?

My Value Configuration

To reproduce my results you will need the following data set:

https://www.dropbox.com/s/qni6zoecmdm9p1x/data.xls?dl=0

Then import the data set and use the following set up:

Y = Table[dta[[j]][[1]], {j, 1, 100}]; 
W = Table[dta[[j]][[3]], {j, 1, Length[Y]}];
ES = Table[dta[[j]][[2]], {j, 1, Length[Y]}]; 
T = Table[t[i], {i, 1, Length[Y]}]; 
TC = Table[t[i] >= 0., {i, 1, Length[Y]}]; 
TS =  Table[{t[i], 0.}, {i, 1, Length[Y]}];
B = 2791967732

Minor Update

I have tried to let FindMinimum only evaluate numerically by compiling the aforementioned GWSUB function with "RuntimeOptions" -> {"EvaluateSymbolically" -> False}. While the calculations of the GWSUB function are faster, the call to FindMinimum still resulted in the same error message.

$\endgroup$
14
  • 2
    $\begingroup$ Can you please post your Mathematica code in actual copy-and-pastable form, properly-formatted? Using Tex to display your Mathematica code is inconvenient, because we can't just copy and paste into our own versions of Mathematica. In addition, we'll probably need all the definitions, e.g. the definition for T and TC. $\endgroup$
    – march
    Commented Feb 19, 2016 at 16:38
  • $\begingroup$ In addition, there are some very strange things going on. Why do you have both 0*(Plus @@ T) and (Plus @@ T) == B as equations? The first isn't even an equation (and it evaluates to zero anyway). Can you check your syntax and your definitions first? $\endgroup$
    – march
    Commented Feb 19, 2016 at 16:42
  • $\begingroup$ Hello March,it is a feasibility problem. That means, I am minimizing zero subject to constraints, so that any value satisfying the constraints minimizes the expression. $\endgroup$ Commented Feb 19, 2016 at 16:49
  • $\begingroup$ Ok, is this acceptable regarding the formatting and the definitions? $\endgroup$ Commented Feb 19, 2016 at 17:05
  • 1
    $\begingroup$ Oh, it worked. When I tried it on a smaller dataset, I got sensible results. But I'll try FindInstance. $\endgroup$ Commented Feb 19, 2016 at 17:09

1 Answer 1

1
$\begingroup$

Ok, I have not figured out what the specific error code is but I have reformulated the objective function so that MMA can actually process the constraint.

The objective function now is:

 ObJ[y_, ES_, t_, w_, k_] := Module[{yt, ytw, Gini},
 yt = (y + t)/ES;
 ytw = (w*(y + t))/ES;
 If[-(k*(2*(Plus @@ w)*(Plus @@ ytw))) +Sum[ (w[[j]]*(Plus  @@ Abs[ytw - yt[[j]]*w]),{j,1,Lentgth[y]}] <= 0
, 0, \[Infinity] ]
 ]

Now the constraint is part of the objective function and FindMinimum seems to process this just fine.

However, the processing speed is still very slow. I have run the same program in Matlab and it was worked out in a couple of minutes. MMA is still running.

$\endgroup$
2
  • $\begingroup$ Can you rewrite your Sum as a Total? And is there a way that you could re-write the Gini expression to use a squared value rather than the Abs function? $\endgroup$
    – MarcoB
    Commented Feb 28, 2016 at 0:38
  • $\begingroup$ Hi @MarcoB, I don't think that I can get around using at least one sum without resorting to a covariance formulation of the Gini, which I do not want to use, since that would depend on assigning ranks, which is quite cumbersome with equivalence scales and weights. The idea of using a squared value is interesting. I haven't tried that. $\endgroup$ Commented Feb 28, 2016 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.