Dynamic Planning-processing sequence Problems

Source: Internet
Author: User
Import Java. util. arraylist; import Java. util. arrays; import Java. util. collections; import Java. util. comparator; import Java. util. list; Class Job implements comparable <job> {int T1; int T2; int ID; public job (int id, int T1, int T2) {This. id = ID; this. t1 = T1; this. t2 = t2;} public int compareto (job o) {// T1 non-descending sorting if (this. t1 <O. t1) Return-1; elsereturn 1 ;}} class com implements comparator <job> {public int compare (job O1, job O2) {If (o1.t2 <o2.t2) return 1; elsereturn-1 ;}} public class machiningorder {public static void main (string ARGs []) {job jobs [] = {new job (, 7), new job, 2), new job (, 6), new job (, 18), new job (, 3), new job (, 10), new job, 4)}; List <job> J = arrays. aslist (jobs); getsequence (j);} public static void getsequence (list <job> jobs) {list <job> n1 = new arraylist <job> (); list <job> n2 = new arraylist <job> (); For (INT I = 0; I <jobs. size (); I ++) {If (jobs. get (I ). t1 <jobs. get (I ). t2) n1.add (jobs. get (I); elsen2.add (jobs. get (I);} collections. sort (N1); collections. sort (N2, new COM (); system. out. println ("processing sequence"); For (INT I = 0; I <n1.size (); I ++) system. out. print (n1.get (I ). ID); For (INT I = 0; I <n2.size (); I ++) system. out. print (n2.get (I ). ID) ;}}/** processing sequence problem * two machines are working in the pipeline. The product is processed by the first machine and then processed by the second machine, find * Minimum Total time after processing all items * idea: * 1. m1 [I] indicates the time spent on the first machine * m2 [I] indicates the processing time on the second machine * 2. in N1, n1 = {I | m1 [I] <m2 [I]} n2 = {I | m1 [I]> m2 [I]} * 3. sort the parts in N1 by non-subtraction and by non-increment in N2 * 4. set n1n2 as the required sequence **/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.