help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Displaying non-zero values only


From: xypron
Subject: Re: [Help-glpk] Displaying non-zero values only
Date: Sat, 25 Oct 2008 05:52:24 -0700 (PDT)

Hello Yaron,

set I := 1..8;
set J := 1..8;
set A dimen 3 := { (3, 4, 2), (7, 8, 1) };
var v{i in I, j in J}, >= 0;
minimize sum : sum{i in I, j in J} v[i,j];
s.t. constraint {(i,j,x) in A}:
  v[i,j] >=  x;
solve;
table result { i in I, j in J : v[i,j] > 0 } OUT 'iODBC'
  'DSN=glpk;UID=glpk;PWD=gnu'
  'DROP TABLE IF EXISTS yaron_result'
  'CREATE TABLE yaron_result (i INT, j INT, v INT )'
  'yaron_result' :
  i, j, v[i,j];
printf "Non-zero results\n";
for { i in I, j in J : v[i,j] > 0 }
  printf "v[%d, %d] = %d\n", i, j, v[i,j];
end;

Best regards

Xypron


kretch wrote:
> 
> Hi All.
> I'm solving a diet problem, and would like to display only the values of
> foods which have non-zero quantities.
> I'm using tables to formulate both input and output, so any information
> which would enable me to write just the non-zero variables to a table
> would
> be most appreciated.
> 
> Thanks
> Yaron
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Displaying-non-zero-values-only-tp20163644p20163877.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.





reply via email to

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