[Help-glpk] Can GLPK for JAVA solve multi-objective optimization

2011-08-01 Thread Zong, Yi


Hi!
I have an objective function described as following, which is lineal:
  [cid:image005.png@01CC484D.FB6B32D0]

 The optimized variables are [cid:image003.png@01CC502C.5A6B0D10] , which 
are integers in [0, 10],
[cid:image004.png@01CC502C.5A6B0D10]is a lineal function of 
[cid:image003.png@01CC502C.5A6B0D10]  an[cid:image006.png@01CC502C.5A6B0D10]
[cid:image007.png@01CC502C.5A6B0D10], and [cid:image008.png@01CC502C.5A6B0D10]  
And W is a weight value.

   Can I use GLPK for JAVA to get the optimized results? If it is possible, 
could you give me an example?

Thank you in advance,


Yi Zong

Scientist

Intelligent Energy Systems



Technical University of Denmark

[cid:image002.gif@01CC484B.D8C57CB0]

Risø National Laboratory for Sustainable Energy

Frederiksborgvej 399,

Building 776

4000  Roskilde

Direct +45 4677 5045

y...@risoe.dtu.dkmailto:d...@risoe.dtu.dk

www.risoe.dtu.dkhttp://www.risoe.dtu.dk/



inline: image001.gifinline: image002.gifinline: image005.pnginline: image007.pnginline: image014.pnginline: image015.pnginline: image016.pnginline: image017.pnginline: image003.pnginline: image004.pnginline: image006.pnginline: image007.pnginline: image008.png___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk


Re: [Help-glpk] implementing constraints in Scala

2011-08-01 Thread name name
How can I print hole model, objective + constrains ?
Set the uper bount to infinity and get uper/lower bount of a variable?

On Sun, Jul 31, 2011 at 6:58 PM, glpk xypron xypron.g...@gmx.de wrote:

 Hello Onor,

 for (i - 0 to col.size-1) {
   GLPK.glp_set_obj_coef(lp, i,coef(i))
 }
 if you have n columns, GLPK number these 1 to n. You possibly
 wanted to write:
  GLPK.glp_set_obj_coef(lp, i + 1,coef(i))

 Cf. sample.c on page 15 of glpk-4.45/doc/glpk.pdf

GLPK.glp_set_col_bnds(lp, colId+1, GLPKConstants.GLP_LO, 0,1000)
 The number 1000 will be ignored.
 The lower bound will be set to 0.

 Best regards

 Xypron

  Original-Nachricht 
  Datum: Sun, 31 Jul 2011 16:07:01 +0200
  Betreff: Re: [Help-glpk] implementing constraints in Scala

  thank you very much I have some more question
 
  there is a problem I got no solution and i dont knew why.
 
  Could you tell me in which function(s) is the problem?
 
  the contraints I did as you told me. I change only GLP_UP; FX
 
 
  startModelBuilding(nbRows : Int, nbCols : Int){
  lp = GLPK.glp_create_prob()
  GLPK.glp_add_cols(lp, nbCols)
  }
 
def setBounds(colId : Int, low : Double, up : Double) {
  GLPK.glp_set_col_bnds(lp, colId+1, GLPKConstants.GLP_DB, low, up)
}
 
def setUnboundUpperBound(colId : Int) {
GLPK.glp_set_col_bnds(lp, colId+1, GLPKConstants.GLP_LO, 0,1000)
}
 
  def addObjective(coef : Array[Double], col : Array[Int], minMode :
  Boolean = true) {
  GLPK.glp_set_obj_name(lp, objective);
  GLPK.glp_set_obj_dir(lp, if (minMode) GLPKConstants.GLP_MIN else
  GLPKConstants.GLP_MAX)
  for (i - 0 to col.size-1) {
GLPK.glp_set_obj_coef(lp, i,coef(i))
  }
  }
 
  def solveModel() : Int = {
println(solveModel);
  val iocp = new glp_iocp();
  GLPK.glp_init_iocp(iocp);
  iocp.setPresolve(
  GLPKConstants.GLP_ON);
  val ret = GLPK.glp_intopt(lp, iocp);
 
  if (ret == 0) {
sol = Array.tabulate(nbCols)(col = GLPK.glp_mip_col_val(lp,col
  +1))
objectiveValue = GLPK.glp_mip_obj_val(lp)
 
ret
  } else {
  System.out.println(The problem could not be solved);
  ret

 --
 Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
 belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk


Re: [Help-glpk] implementing constraints in Scala

2011-08-01 Thread Xypron

Hello Onor,

you can save the whole model to a file (using glp_write_lp() or 
glp_write_prob()) and then print the file.


When you use glp_set_col_bnds() or glp_set_row_bnds to set the lower 
bound (GLP_LO), the upper bound is set to infinity.


You can use glp_get_row_lb(), glp_get_row_ub(), glp_get_col_lb(), 
glp_get_col_ub() for retrieving the bounds.


Please, study glpk-4.45/doc/glpk.pdf available in the source 
distribution of GLPK:

ftp://ftp.gnu.org/gnu/glpk/glpk-4.45.tar.gz

Best regards

Xypron.

On 01.08.2011 10:26, name name wrote:

How can I print hole model, objective + constrains ?
Set the uper bount to infinity and get uper/lower bount of a variable?




___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk


Re: [Help-glpk] Can GLPK for JAVA solve multi-objective optimization

2011-08-01 Thread Xypron


  
  
Hello Yi,

yes you can do the optimization with GLPK for Java.

Please, study the examples files provided with GLPK for Java, e.g.
glpk-java-1.0.15/examples/java/Mip.java

You can download the source of GLPK for Java from
http://glpk-java.sourceforge.net.

For the documentation of the GLPK API, please, read
glpk-4.45/doc/glpk.pdf available in the source distribution of GLPK
ftp://ftp.gnu.org/gnu/glpk/glpk-4.45.tar.gz

Best regards

Xypron


On 01.08.2011 09:21, Zong, Yi wrote:

  
  
  
  
  


Hi!
I have an objective function described as
  following, which is lineal:
 

 The optimized variables are
  , which are integers in [0, 10],
is a lineal function of an
, and  And
  W is a weight value.

 Can I use GLPK for JAVA to get
  the optimized results? If it is possible, could you give me an
  example?

Thank you in advance,



  

  
Yi Zong
  
  


  
Scientist 
  


  
Intelligent
Energy Systems 
  


  

  


  
Technical University of Denmark
  
  

  


  
Ris
National Laboratory for Sustainable Energy 
  


  
Frederiksborgvej
399, 
  


  
Building
776 
  


  
4000
Roskilde 
  


  
Direct
+45 4677 5045 
  


  
y...@risoe.dtu.dk

  


  
www.risoe.dtu.dk

  

  



  
  

___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk



  

___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk


[Help-glpk] [Fwd: [Fwd: Re: Initializing a few decision variables]]

2011-08-01 Thread Andrew Makhorin
 Forwarded Message 
From: mgoet...@isye.gatech.edu
To: help-glpk@gnu.org
Subject: [Fwd: Re: [Help-glpk] Initializing a few decision variables]
Date: Mon, 1 Aug 2011 12:00:38 -0400

I added two arrays of equal dimensions to the set, FT and FS, and
initialized them in the data section
They hold the paired values for the initial assignments.
set FT :=D1 B2 D2 B3 B1;
set FS := 1  2  4  5  7;

I added the following statement to the model

s.t. init{f in FT,}: x[f,FS[f]] = 1;

the error is that FS cannot be subscripted.

Basic question remains on how to specify the initial assignment constraint
in the model section
and how to specify the pairs of initial assigments in the data section.
Thanks




if B1 is a set, you probably want to write:

s.t. {b in B1} c1 : x[b,21] = 1;
# or
s.t. c2 : x[b,21] = 1; # where b is a member of B1

Best regards

Xypron


On 29.07.2011 16:45, Marc Goetschalckx wrote:
 I am using a model coded in GMPL.
 The model has a large two-dimensional array of x variables, one
 dimension has literal indices that are defined in a set in the data
 segment (example is B1)
 This model is running and solving so far.
 However, I need to initialize a very few of the x variables because of
 boundary conditions.
 Statement in the model section is similar to
 s.t. x[B1,21]=1;
 This cannot be done because B1 is not yet defined (from the data
 section).
 How can I initialize some of the variables in the data section, or
 what is the sequence of actions that can achieve this.
 Thanks.







___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk


Re: [Help-glpk] [Fwd: [Fwd: Re: Initializing a few decision variables]]

2011-08-01 Thread Andrew Makhorin
 I added two arrays of equal dimensions to the set, FT and FS, and
 initialized them in the data section
 They hold the paired values for the initial assignments.
 set FT :=D1 B2 D2 B3 B1;
 set FS := 1  2  4  5  7;
 
 I added the following statement to the model
 
 s.t. init{f in FT,}: x[f,FS[f]] = 1;
 
 the error is that FS cannot be subscripted.
 
 Basic question remains on how to specify the initial assignment constraint
 in the model section
 and how to specify the pairs of initial assigments in the data section.

In the model section:

set F, dimen 2;
s.t. init{(i,j) in F}: x[i,j] = 1;

In the data section:

set F := D1 1, B2 2, D2 4, B3 5, B1 7;

Please see also examples included in glpk distribution.


___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk