help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-glpk] Applying a threshold to the solution using GMPL?


From: Reginald Beardsley
Subject: [Help-glpk] Applying a threshold to the solution using GMPL?
Date: Sat, 9 Nov 2013 08:19:11 -0800 (PST)

I'm solving Ax=b using an L1 norm.  In some cases I get a number of relatively 
small values in x that I would like to suppress based on the fraction of the 
result that they contribute so as to make the solution more sparse.

Unfortunately I'm unable to recognize from the examples in the distribution 
(4.45) or the discussion in the AMPL book how to implement this using GMPL.  
The following model file shows what I'm trying to do.  I'd like to apply a 
constraint such that:

(sum{i in I}(A[i,j,k]*X[j,k]/b[i]))/ii >= threshold

It seems to me analogous to the addition of fixed costs in the transportation 
problem, but the translation to my problem escapes me.

Thanks,
Reg


# array limits
param ii;
param jj;
param kk;

# array indices
set I := 1..ii;
set J := 1..jj;
set K := 1..kk;

param b{I} ,>=0;

param A{I,J,K} ,>=0;  

# solution variables
var X{J,K} ,>=0;  

# slack variables
var u{I} ,>=0;
var v{I} ,>=0;

# objective
minimize error: sum{i in I}(u[i]+v[i]);

#constraints
s.t. eq{i in I}:sum{j in J} (sum{k in K}A[i,j,k]*X[j,k])
                            + u[i] - v[i] = b[i];
solve;

# solution output

for{k in K}{
   printf{j in J:X[j,k]>0} "Tst: %15.8g %8.6f \n" 
                  ,X[j,k] ,(sum{i in I}(A[i,j,k]*X[j,k]/b[i]))/ii;
}

end;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]