/[ascend]/trunk/base/generic/solver/slv8.c
ViewVC logotype

Diff of /trunk/base/generic/solver/slv8.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1035 by johnpye, Mon Nov 6 07:49:06 2006 UTC revision 1036 by johnpye, Thu Jan 4 07:40:26 2007 UTC
# Line 2607  static void update_block_information(slv Line 2607  static void update_block_information(slv
2607  }  }
2608    
2609    
2610  static void slv8_presolve(slv_system_t server, SlvClientToken asys){  static int slv8_presolve(slv_system_t server, SlvClientToken asys){
2611    struct var_variable **vp;    struct var_variable **vp;
2612    struct rel_relation **rp;    struct rel_relation **rp;
2613    int32 cap, ind;    int32 cap, ind;
# Line 2622  static void slv8_presolve(slv_system_t s Line 2622  static void slv8_presolve(slv_system_t s
2622    check_system(sys);    check_system(sys);
2623    if( sys->vlist == NULL ) {    if( sys->vlist == NULL ) {
2624      ERROR_REPORTER_HERE(ASC_PROG_ERR,"Variable list was not set.");      ERROR_REPORTER_HERE(ASC_PROG_ERR,"Variable list was not set.");
2625      return;      return -1;
2626    }    }
2627    if( sys->rlist == NULL && sys->obj == NULL ) {    if( sys->rlist == NULL && sys->obj == NULL ) {
2628      ERROR_REPORTER_HERE(ASC_PROG_ERR,"Relation list and objective were not set.");      ERROR_REPORTER_HERE(ASC_PROG_ERR,"Relation list and objective were not set.");
2629      return;      return -2;
2630    }    }
2631    
2632    sys->obj = slv_get_obj_relation(server); /*may have changed objective*/    sys->obj = slv_get_obj_relation(server); /*may have changed objective*/
2633    
2634    if(!sys->obj){    if(!sys->obj){
2635      ERROR_REPORTER_HERE(ASC_PROG_ERR,"No objective function was specified");      ERROR_REPORTER_HERE(ASC_PROG_ERR,"No objective function was specified");
2636      return;      return -3;
2637    }    }
2638    
2639    if(sys->presolved > 0) { /* system has been presolved before */    if(sys->presolved > 0) { /* system has been presolved before */
# Line 2787  static void slv8_presolve(slv_system_t s Line 2787  static void slv8_presolve(slv_system_t s
2787    update_status(sys);    update_status(sys);
2788    iteration_ends(sys);    iteration_ends(sys);
2789    sys->s.cost[sys->s.block.number_of].time=sys->s.cpu_elapsed;    sys->s.cost[sys->s.block.number_of].time=sys->s.cpu_elapsed;
2790    
2791      return 0;
2792  }  }
2793    
2794  /**  /**
# Line 2825  static void slv8_resolve(slv_system_t se Line 2827  static void slv8_resolve(slv_system_t se
2827    sys->objective =  MAXDOUBLE/2000.0;    sys->objective =  MAXDOUBLE/2000.0;
2828    
2829    update_status(sys);    update_status(sys);
2830      return 0;
2831  }  }
2832    
2833  /**  /**
2834      @TODO document this      @TODO document this
2835  */  */
2836  static void slv8_iterate(slv_system_t server, SlvClientToken asys){  static int slv8_iterate(slv_system_t server, SlvClientToken asys){
2837    slv8_system_t sys;    slv8_system_t sys;
2838    FILE              *mif;    FILE              *mif;
2839    FILE              *lif;    FILE              *lif;
2840    sys = SLV8(asys);    sys = SLV8(asys);
2841    mif = MIF(sys);    mif = MIF(sys);
2842    lif = LIF(sys);    lif = LIF(sys);
2843    if (server == NULL || sys==NULL) return;    if (server == NULL || sys==NULL) return -1;
2844    if (check_system(SLV8(sys))) return;    if (check_system(SLV8(sys))) return -2;
2845    if( !sys->s.ready_to_solve ) {    if( !sys->s.ready_to_solve ) {
2846      ERROR_REPORTER_HERE(ASC_PROG_ERR,"Not ready to solve.");      ERROR_REPORTER_HERE(ASC_PROG_ERR,"Not ready to solve.");
2847      return;      return 1;
2848    }    }
2849    
2850    if (sys->s.block.current_block==-1) {    if (sys->s.block.current_block==-1) {
# Line 2870  static void slv8_iterate(slv_system_t se Line 2873  static void slv8_iterate(slv_system_t se
2873      update_cost(sys);      update_cost(sys);
2874      iteration_ends(sys);      iteration_ends(sys);
2875      update_status(sys);      update_status(sys);
     return;  
2876    }    }
2877    
2878      return 0;
2879  }  }
2880    
2881  /**  /**
2882      @TODO document this      @TODO document this
2883  */  */
2884  static void slv8_solve(slv_system_t server, SlvClientToken asys){  static int slv8_solve(slv_system_t server, SlvClientToken asys){
2885    slv8_system_t sys;    slv8_system_t sys;
2886      int err = 0;
2887    sys = SLV8(asys);    sys = SLV8(asys);
2888    if (server == NULL || sys==NULL) return;    if (server == NULL || sys==NULL) return -1;
2889    if (check_system(sys)) return;    if (check_system(sys)) return -2;
2890    while( sys->s.ready_to_solve ) slv8_iterate(server,sys);    while( sys->s.ready_to_solve )err = err | slv8_iterate(server,sys);
2891      return err;
2892  }  }
2893    
2894  /**  /**

Legend:
Removed from v.1035  
changed lines
  Added in v.1036

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22