Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A simple program that computes the Cutting Stock Problem using the glpk library

License

NotificationsYou must be signed in to change notification settings

swasun/CuttingStockProblem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple program that computes the Cutting Stock Problem using theglpk library (https://en.wikipedia.org/wiki/GNU_Linear_Programming_Kit) (old school project, Algorithmic and Operations Reseach class, 2017).

Dependency

On Debian, you can installglpk with the following command:

apt install libglpk-dev

Otherwise, this is the sitehttps://www.gnu.org/software/glpk/ of the project and the repositoryhttp://cvs.savannah.gnu.org/viewvc/glpk/.

Usage

mkdir bin && mkdir obj && make./bin/cutting_stock <file_name>

Using the code

#include"order.h"#include"column.h"#include"cutting_stock.h"#include<glpk.h>intmain(intargc,char**argv) {order**orders;intorder_count,max_width,best_patterns_number;double**best_patterns,*pattern_demand_repartition,obj_value;glp_term_out(GLP_OFF);orders=NULL;pattern_demand_repartition=NULL;best_patterns=NULL;pattern_demand_repartition=NULL;if (!(orders=orders_read_from_file(argv[1],&order_count,&max_width))) {/* Error handling here */        gotoclean_up;    }if (!(best_patterns=cutting_stock_compute_best_patterns(orders,order_count,max_width,&best_patterns_number))) {/* Error handling here */        gotoclean_up;    }if (!(pattern_demand_repartition=cutting_stock_compute(best_patterns,best_patterns_number,orders,order_count,&obj_value))) {/* Error handling here */        gotoclean_up;    }cutting_stock_print_solution(best_patterns,best_patterns_number,order_count,pattern_demand_repartition,obj_value,orders,order_count,stdout);clean_up:free((void*)pattern_demand_repartition);columns_matrix_destroy(best_patterns,best_patterns_number);orders_destroy(orders,order_count);glp_free_env();return0}

Experiments

On 100 orders:

./bin/cutting_stock res/instance1.txt Execution of the algorithm in 0.000662s.Pattern { 2x45 } x 48.500000Pattern { 2x36 } x 100.750000Pattern { 2x36 2x14} x 105.500000Pattern { 1x36  2x31 } x 197.500000Objective value : 452.250000

On 100 orders:

./bin/cutting_stock res/instance2.txtExecution of the algorithm in 0.009895s.[...]Objective value : 858.214286

On 10000 orders:

./bin/cutting_stock res/instance3.txtExecution of the algorithm in 0.267057s.[...]Objective value : 1065.000000

Authors

  • Charly Lamothe
  • Doulkifouli Abdallah-Ali

About

A simple program that computes the Cutting Stock Problem using the glpk library

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp