bath_log.run 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # CLEAR MEMORY
  2. reset ;
  3. # set search path
  4. #option ampl_include '/home/moez/Downloads/amplide.linux64/amplide/';
  5. # LOAD MODEL
  6. model 'bath_log.mod' ;
  7. #model bath.mod ;
  8. # LOAD DATA
  9. data 'bath_log-4.dat' ;
  10. #data bath.dat ;
  11. # Approximation grid
  12. let q := q0 + 1;
  13. param dL := L / q0 ;
  14. param nL := ( Mbar - M0 ) div L ;
  15. param q1 := 1+( ( Mbar - nL * L - M0 ) div dL );
  16. # param n := q1 * ( nL + 1 ) + (q0-q1+2)*nL ;
  17. let n := q * nL + q1 + 1 ;
  18. param M1 := Mbar - nL * L ;
  19. for { i in 1..q1 } {
  20. for { j in 0 .. nL+1 } {
  21. let B[i+j*q] := M0 + (i-1) * dL + j * L;
  22. }
  23. }
  24. for {j in 0 .. nL+1 } {
  25. let B[q1+1+j*q] := M1 + j * L ;
  26. }
  27. for { i in q1+2..q } {
  28. for { j in 0 .. nL } {
  29. let B[i + j * q] := B[q1] + dL * (i - (q1+1)) + j * L;
  30. }
  31. }
  32. # Print initial solution
  33. display t[n+q] , util_log;
  34. # Provide solver (change depending on machine)
  35. option solver "/home/moez/ulco/ampl/conopt" ;
  36. #option solver ipopt ;
  37. #option solver "/home/moez/ulco/ampl/minos" ;
  38. objective last_arrival_time;
  39. solve ;
  40. display t[n+q] , util_log;
  41. option conopt_options 'outlev=3';
  42. option display_width 100 ;
  43. # The logarithlic utility
  44. objective util_log ;
  45. # Solve
  46. solve ;
  47. # Compute arrival time for each mass
  48. var tt {i in 1..n} = t[i+q] ;
  49. # Print solution
  50. display t[n+q] , util_log, util_log / P;
  51. display B, e, k, v, ue_log, ux_log, t, tt ;
  52. # Export solution to csv file
  53. display B, e, k, v, ue_log, ux_log, t,tt > 'sol4.csv' ;
  54. end;