Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark mode
Gurobi Example Tour
Light LogoDark Logo
Gurobi
Back to top

lpmethod.R#

# Copyright 2025, Gurobi Optimization, LLC## Solve a model with different values of the Method parameter;# show which value gives the shortest solve time.library(Matrix)library(gurobi)args<-commandArgs(trailingOnly=TRUE)if(length(args)<1){stop('Usage: Rscript lpmethod.R filename\n')}# Read modelcat('Reading model',args[1],'...')model<-gurobi_read(args[1])cat('... done\n')# Solve the model with different values of Methodparams<-list()bestTime<-InfbestMethod<--1for(iin0:4){params$method<-ires<-gurobi(model,params)if(res$status=='OPTIMAL'){bestMethod<-ibestTime<-res$runtimeparams$TimeLimit<-bestTime}}# Report which method was fastestif(bestMethod==-1){cat('Unable to solve this model\n')}else{cat('Solved in',bestTime,'seconds with Method:',bestMethod,'\n')}rm(params,model)

Help and Feedback


[8]
ページ先頭

©2009-2025 Movatter.jp