Revision 1513 trunk/src/nh99/model12.cpp
model12.cpp (revision 1513)  

2  2 
* $Id$ 
3  3 
* 
4  4 
* Author: David Fournier 
5 
* Copyright (c) 20082012 Regents of the University of California


5 
* Copyright (c) 20082014 Regents of the University of California


6  6 
*/ 
7  7 
#include <admodel.h> 
8  8  
9  9 
void initial_params::save(const ofstream& _ofs, int prec) 
10 
{ 

11 
ofstream& ofs=(ofstream&)_ofs; 

12 
ofs << setw(prec+6) << setshowpoint(); 

13 
for (int i=0;i<num_initial_params;i++) 

10  14 
{ 
11 
ofstream& ofs=(ofstream&) _ofs; 

12 
ofs << setw(prec+6) << setshowpoint(); 

13 
for (int i=0;i<num_initial_params;i++) 

14 
{ 

15 
(varsptr[i])>save_value(ofs,prec); 

16 
} 

15 
(varsptr[i])>save_value(ofs,prec); 

17  16 
} 
17 
} 

18  18  
19  19 
void param_init_number::save_value(const ofstream& _ofs, int prec) 
20 
{


21 
ofstream& ofs=(ofstream&) _ofs;


22 
#ifndef __ZTC__


23 
ofs << setprecision(prec) << dvariable(*this) << endl;


24 
#else


25 
ofs << setw(prec+6) << setprecision(prec) << *this << endl;


26 
#endif


27 
}


20 
{ 

21 
ofstream& ofs=(ofstream&)_ofs;


22 
#ifndef __ZTC__ 

23 
ofs << setprecision(prec) << dvariable(*this) << endl; 

24 
#else 

25 
ofs << setw(prec+6) << setprecision(prec) << *this << endl; 

26 
#endif 

27 
} 

28  28  
29  29 
void param_init_vector::save_value(const ofstream& _ofs, int prec) 
30 
{ 

31 
ofstream& ofs=(ofstream&)_ofs; 

32 
ofs << setw(prec+6) << setprecision(prec) << dvar_vector(*this) << endl; 

33 
} 

34  
35 
void param_init_bounded_vector::save_value(const ofstream& _ofs, int prec) 

36 
{ 

37 
ofstream& ofs=(ofstream&)_ofs; 

38 
ofs << setw(prec+6) << setprecision(prec) << dvar_vector(*this) << endl; 

39 
} 

40  
41 
void param_init_matrix::save_value(const ofstream& _ofs, int prec) 

42 
{ 

43 
ofstream& ofs=(ofstream&)_ofs; 

44 
ofs << setw(prec+6) << setprecision(prec) << dvar_matrix(*this) << endl; 

45 
} 

46  
47 
void param_init_number::save_value(const ofstream& _ofs, int prec, const dvector& g, int& offset) 

48 
{ 

49 
ADUNCONST(ofstream,ofs) 

50 
ofs << label() << " " 

51 
<< setw(prec+6) << setprecision(prec) << *this << " " 

52 
<< setw(prec+6) << setprecision(prec) << g(offset++) << endl; 

53 
} 

54  
55 
void param_init_vector::save_value(const ofstream& _ofs, int prec, const dvector& g, int& offset) 

56 
{ 

57 
ADUNCONST(ofstream,ofs) 

58 
int mmin=indexmin(); 

59 
int mmax=indexmax(); 

60 
for (int i=mmin;i<=mmax;i++) 

30  61 
{ 
31 
ofstream& ofs=(ofstream&) _ofs; 

32 
ofs << setw(prec+6) << setprecision(prec) << dvar_vector(*this) << endl; 

62 
ofs << label() 

63 
<< "(" << i << ") " 

64 
<< setw(prec+6) << setprecision(prec) << (*this)(i) << " " 

65 
<< setw(prec+6) << setprecision(prec) << g(offset++) << endl; 

33  66 
} 
67 
} 

34  68  
35 
void param_init_bounded_vector::save_value(const ofstream& _ofs, int prec) 

69 
void param_init_bounded_vector::save_value(const ofstream& _ofs, int prec, const dvector& g, int& offset) 

70 
{ 

71 
ADUNCONST(ofstream,ofs) 

72 
int mmin=indexmin(); 

73 
int mmax=indexmax(); 

74 
for (int i=mmin;i<=mmax;i++) 

36  75 
{ 
37 
ofstream& ofs=(ofstream&) _ofs; 

38 
ofs << setw(prec+6) << setprecision(prec) << dvar_vector(*this) << endl; 

76 
ofs << label() 

77 
<< "(" << i << ") " 
Also available in: Unified diff