[3094] | 1 | %
|
---|
| 2 | % function to write linear constraint list
|
---|
| 3 | %
|
---|
| 4 | function []=lclist_write(fidi,cstring,cstring2,dvar)
|
---|
| 5 |
|
---|
| 6 | if isempty(dvar)
|
---|
| 7 | return;
|
---|
| 8 | end
|
---|
| 9 |
|
---|
| 10 | % put linear constraints into lists for writing
|
---|
| 11 |
|
---|
| 12 | nvar=0;
|
---|
| 13 | pmatrix=[];
|
---|
| 14 | plower =[];
|
---|
| 15 | pupper =[];
|
---|
| 16 | ptarget=[];
|
---|
| 17 | pstype =[];
|
---|
| 18 | pscale =[];
|
---|
| 19 |
|
---|
| 20 | fnames=fieldnames(dvar);
|
---|
| 21 | for i=1:numel(fnames)
|
---|
| 22 | nvar=nvar+numel(dvar.(fnames{i}));
|
---|
| 23 | pmatrix=[pmatrix prop_matrix(dvar.(fnames{i}))];
|
---|
| 24 | plower =[plower prop_lower(dvar.(fnames{i})) ];
|
---|
| 25 | pupper =[pupper prop_upper(dvar.(fnames{i})) ];
|
---|
| 26 | ptarget=[ptarget prop_target(dvar.(fnames{i}))];
|
---|
| 27 | pstype =[pstype prop_stype(dvar.(fnames{i})) ];
|
---|
| 28 | pscale =[pscale prop_scale(dvar.(fnames{i})) ];
|
---|
| 29 | end
|
---|
| 30 |
|
---|
| 31 | % write linear constraints
|
---|
| 32 |
|
---|
| 33 | disp(sprintf(' Writing %d %s linear constraints.',...
|
---|
| 34 | nvar,cstring));
|
---|
| 35 |
|
---|
| 36 | if ~isempty(pmatrix)
|
---|
| 37 | fprintf(fidi,'\t %s_matrix =\n',cstring2);
|
---|
| 38 | vector_write(fidi,sprintf('\t '),pmatrix,6,76);
|
---|
| 39 | end
|
---|
| 40 | if ~isempty(plower)
|
---|
| 41 | fprintf(fidi,'\t %s_lower_bounds =\n',cstring2);
|
---|
| 42 | vector_write(fidi,sprintf('\t '),plower ,6,76);
|
---|
| 43 | end
|
---|
| 44 | if ~isempty(pupper)
|
---|
| 45 | fprintf(fidi,'\t %s_upper_bounds =\n',cstring2);
|
---|
| 46 | vector_write(fidi,sprintf('\t '),pupper ,6,76);
|
---|
| 47 | end
|
---|
| 48 | if ~isempty(ptarget)
|
---|
| 49 | fprintf(fidi,'\t %s_targets =\n',cstring2);
|
---|
| 50 | vector_write(fidi,sprintf('\t '),ptarget,6,76);
|
---|
| 51 | end
|
---|
| 52 | if ~isempty(pstype)
|
---|
| 53 | fprintf(fidi,'\t %s_scale_types =\n',cstring2);
|
---|
| 54 | vector_write(fidi,sprintf('\t '),pstype ,6,76);
|
---|
| 55 | end
|
---|
| 56 | if ~isempty(pscale)
|
---|
| 57 | fprintf(fidi,'\t %s_scales =\n',cstring2);
|
---|
| 58 | vector_write(fidi,sprintf('\t '),pscale ,6,76);
|
---|
| 59 | end
|
---|
| 60 |
|
---|
| 61 | end
|
---|