i++; }
if(i<=this.inbag_object.size()-1) p+=iobject.getvw()*bag_left; return p; }
public int get_bag_weight(){ int w=0;
for(object o:this.inbag_object){ w+=o.getweight(); }
return w; }
public int get_bag_value(){ int w=0;
for(object o:this.inbag_object){ w+=o.getvalue(); }
return w; }
@Override
public int compareTo(Node o) {
// TODO Auto-generated method stub if(this.prio>o.prio) return -1; if(this.prio public boolean isend(){ if(this.node_in==this.outbag_object.size()) return true; else return false; } public ArrayList public int get_node_in(){return this.node_in;} public int get_bag_leftv(){return this.leftv;} public int get_bag_prio(){return this.prio;} public String toString(){ return \+this.node_in+\+this.prio; } } ----------------------------------------------------------------------- package bag01b; public class object implements Comparable private int weihgt; private int value; public object(int w,int v){ super(); this.weihgt=w; this.value=v; this.id=ids++; } public int getid(){return this.id;} public int getweight(){return this.weihgt;} public int getvalue(){return this.value;} public float getvw(){return (float)this.value/this.weihgt;} @Override public int compareTo(object o) { // TODO Auto-generated method stub if(this.getvw()>o.getvw()) return -1; if(this.getvw() public String toString(){ return \+this.id+\; } }
相关推荐: