~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to macros/metanet/min_lcost_flow2.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [c,phi,flag]=min_lcost_flow2(g)
 
2
// Copyright INRIA
 
3
[lhs,rhs]=argn(0)
 
4
if rhs<>1 then error(39), end
 
5
// check g
 
6
check_graph(g)
 
7
// check capacities
 
8
ma=prod(size(g('tail')))
 
9
n=g('node_number')
 
10
mincap=g('edge_min_cap')
 
11
maxcap=g('edge_max_cap')
 
12
if mincap==[] then
 
13
  mincap=zeros(1,ma)
 
14
end
 
15
if maxcap==[] then
 
16
  maxcap=zeros(1,ma)
 
17
end
 
18
verif=find(mincap<>0)
 
19
if verif<>[] then 
 
20
  error('Minimum capacities must be equal to zero')
 
21
end
 
22
verif=find(maxcap<0) 
 
23
if verif<>[] then 
 
24
  error('Maximum capacities must be non negative')
 
25
end
 
26
if or(maxcap<>round(maxcap)) then
 
27
  error('Maximum capacities must be integer')
 
28
end
 
29
// check costs
 
30
costs=g('edge_cost')
 
31
if costs==[] then
 
32
  costs=zeros(1,ma)
 
33
end
 
34
if or(costs<>round(costs)) then
 
35
  error('Costs must be integer')
 
36
end
 
37
// check demand
 
38
demand=g('node_demand')
 
39
if demand==[] then
 
40
  demand=zeros(1,n)
 
41
end
 
42
if or(demand<>round(demand)) then
 
43
  error('Demands must be integer')
 
44
end
 
45
if sum(demand)<>0 then
 
46
  error('Sum of demands must be equal to zero')
 
47
end
 
48
// compute linear min cost flow by relaxation method (Bertsekas)
 
49
[c,phi,flag]=m6relax(g('head'),g('tail'),costs,maxcap,demand,arc_number(g),n)