Writing an objective function for MILP and GA

Hi
I have the following objective function for an optimization problem.
Xij, Yjk, Zj are my decision variables and the other terms are constants where their values are located in an Excel Spread sheet. I have also 7 other constraints and this problem is a MILP one. I was successfully able to use * xlsread* to import the data for objective function and constraints values to solve this problem using _ intlinprog_.
at the moment, i am trying to solve this problem using GA, however, since this is a Mixed integer problem, i was not able to use the built-in GA algorithm in the optimization toolbox nor _ ga_ so now i have to write the ga code from scratch.
my questions are: 1) I am trying to rewrite the objective function without using xlsread (i.e. i want to call the values from excel, and provide indices for Xij, Yjk and Zi, however this seems tedious since the total number of decision variables is 2180. even if i attempt a for-loop i am not sure how to link the constants (pulled from Excel or a matrix) to their corresponding decision variable.
2)What are my options for writing the constraints other than a penalty function?
thank you so much for the help.

1 Comment

hi, may please share with me how you solved your intlinprog problem.

Sign in to comment.

Answers (2)

I strongly suggest that you use intlinprog for your problem and do not attempt to use ga, as the mixed-integer nonlinear programming solver in ga is intended for problems having fewer than 100 variables. Seriously, you are doing yourself a disservice by considering ga for this kind or problem. You have a linear objective and I would bet that your constraints (whatever they are) can be linearized, perhaps along the lines of this example.
As for speeding things up, you should never have xlsread inside an objective function. Use it once to get variables into the MATLAB workspace, then use the MATLAB variables in further computations.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
thank you Sir for your answer,
i actually have already used intlinprog for this problem and already got the results. i am trying to utilize my own ga to solve it for research purposes. My current main issue is writing the objecive/fitness function in the form of SUM(x(i)*corresponding parameters)+SUM(y(i)*corresponding parameters)+SUM(z(i)*corresponding parameters).
i have been doing my google/mathworks search, and i know that i have to have a (1x320) matrix for x(i) and (1x1840) matrix for y(i) and a (1x20) for z(i) in order to get a scalar output for my objective function.
i have the following code for extracting the parameters data from excel and isolating them as per x,y,z decision variables, but i need to be directed properly to move from there.
OBJFP = xlsread('solver.xlsx','Parameters for OBJ','DN1:DN2180');
FCM = OBJFP(1:320); % Xij Parameters
CM2R= OBJFP(321:2160);% Yjk Parameters
FC = OBJFP(2161:2180); % Zi Parameters
thank you again for your help.
BR

1 Comment

Once you have the variables in the MATLAB workspace, you can pass them to your functions as extra parameters, along the lines suggested by Passing Extra Parameters.
It pains me to think of you trying to solve an MILP using a genetic algorithm. This is not a productive use of your time.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

Categories

Asked:

on 9 Oct 2018

Commented:

on 14 Apr 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!