Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
Automating an optimization routine

Subject: Automating an optimization routine

From: Gareth Lennox

Date: 17 Nov, 2010 01:52:04

Message: 1 of 2

Hello Everybody,

I'm a long time reader, first time begger! I wonder if anyone can help me automate an optimization routine. So basically i'm trying to solve maximum coverage problems. I'm using Matlab 2009 with the TOMLAB package that integrates cplex. These maximal coverage problems are in the context of conservation reserve selections and they have the following mathematical form (written mostly in latex speak),

\max \sum_{i in I} y_{i}

subject to, \sum_{j \in N_{i}} x_{j} >= y_{i} for all i \in I

\sum_{j \in J} c_{j}.*x_{j} <= B

where J is index set of candidate reserves, I denotes the index set of species that can be covered and N_{i}, a subset of J, is the set of candidate reserves that contain species i of the population. x_{j} and y_{i} are binary variables. x_{j} = 0 indicates that site j is not selected, 1 that it is. y_{i} = 0 indicates that species i is not in any of the selected reserves, 1 that it is in at least 1.

So all this site by species (that is site 1 is row one, for example) info would be stored in a matrix with the costs in a vector. A trivial example would be something like

A = [1 0 1;
        0 0 1;
        1 1 0];

c = [50 50 50]; B = 100;

The code to solve this becomes

toms -integer y1 y2 y3 x1 x2 x3
bnds = {0 <= [y1;y2;y3;y4;y5;y6;x1;x2;x3;x4] <= 1};
con = {y1<=x1+x3;
       49*(x1+x2+x3) <= 100};
   obj = -(y1+y2+y3);
[sol,res] = ezsolve(obj,{bnds, con});

So what i need to work out is a way for matlab to read the matrix A, the vector C and the scalar B, to then convert that into something that solves the associated optimization and then using the solution is able to update the matrix and/or vector and/or scalar then perform the new optimization.

To anyone who's actually read all this, thank you muchly. To anyone who can help me on the way to the solution, i'll be eternally in your debt (in a non-fiduciary manner :D )



Subject: Automating an optimization routine

From: Gareth Lennox

Date: 17 Nov, 2010 03:56:04

Message: 2 of 2

Update: I worked it out. Was rather easy in the end when i worked out have to apply array functions on the TOMSYM objects and how to then convert such objects back to matlab arrays.



Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us