[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] One more question about how to use GLPK for specific pro
From: |
Dmitriy Yun |
Subject: |
Re: [Help-glpk] One more question about how to use GLPK for specific problem |
Date: |
Thu, 14 Oct 2010 15:53:16 +0700 |
Hi Everyone,
Thank you all for helping suggestions.
Eventually I solved my problem.
I've simplified the gap.mod from examples in glpk-4.44\examples.
I've tested it on my test data and it works!
----------------------------------------------------------------------------------------
modified gap.mod
----------------------------------------------------------------------------------------
/* GAP, Generalized Assignment Problem */
param n, integer, > 0;
/* number of agents */
param m, integer, > 0;
/* number of jobs */
set I := 1..n;
/* set of agents */
set J := 1..m;
/* set of jobs */
param a{i in I, j in J}, >= 0;
/* resource consumed in allocating job j to agent i */
param b{i in I}, >= 0;
/* resource capacity of agent i */
var x{i in I, j in J}, binary;
/* x[i,j] = 1 means job j is assigned to agent i */
s.t. one{j in J}: sum{i in I} x[i,j] = 1;
/* job j must be assigned exactly to one agent */
s.t. lim{i in I}: sum{j in J} a[i,j] * x[i,j] <= b[i];
/* total amount of resources consumed by all jobs assigned to agent i
must not exceed the agent's capacity */
minimize obj: sum{i in I, j in J} a[i,j] * x[i,j];
solve;
printf {j in J, i in I: x[i,j] == 1} "%i,%i;", j-1, i-1;
end;
---------------------------------------------------------------------------------------------
gap.data
---------------------------------------------------------------------------------------------
param n := 3;
param m := 4;
param a : 1 2 3 4 :=
1 7.3 10.8 13.0 2.7
2 9.3 9.0 13.0 8.5
3 5.3 9.0 9.0 12.5;
param b := 1 10.0, 2 18.3, 3 14.2;
---------------------------------------------------------------------------------------------
With best regards,
Dmitry
On Thu, Oct 14, 2010 at 2:29 PM, Pietro Scionti
<address@hidden> wrote:
>
>
> Dmitriy Yun wrote:
>>
>> Yes, I use this wrapper.
>> I used the example from Program.cs to create c# code for my problem
>> (at least I tried to do it).
>> Do you mean that I can use this C# wrapper to load data from .CSV file.
>>
>
> You can load data from CSV using GLPK itself writing the necessary
> instructions in the model. Refer to the tables.PDF documentation file for
> this
>
> Dmitriy Yun wrote:
>>
>> Am I right understand that this C# wrapper is a wrapper for GLPSOL
>> standalone solver?
>>
> This library (kudos to yoyovicks for it) wraps the GLPK API. You can do this
> if you want to use GLPSOL:
> * have your program generate a text file with the model (which itself knows
> where to find its csv data)
> * instantiate a new System.Diagnostic.Process calling the GLPSOL executable
> with the necessary parameters and output redirected to file
> * Read and parse output information from file
>
>
> --
> View this message in context:
> http://old.nabble.com/One-more-question-about-how-to-use-GLPK-for-specific-problem-tp29959318p29959945.html
> Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.
>
>
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-glpk
>
--
With best regards,
Dmitry