You are here: Foswiki>AgMathLife Web>OptimizationWS15>ProgrammingExerciseOptiWS13 (19 Jan 2017, AnnikaRoehl)

## Short Overview

The practical exercises for the lecture Optimization won't be programming exercises. Mostly you have to get familiar with an LP Solver, try to solve LPs and understand the results.

### Assessment

For each exercise you can score 3 Points:

3 Pts = program runs without errors
2 Pts = program contains small errors
1 Pts = program contains critical errors
0 Pts = no program submitted

There will be code reviews on each friday after the deadlines.

### Exercise 1: MATLAB

Deadline: 17.12.2015, 8:00 a.m.

### Exercise 2: Flux Balance Analysis

Deadline: 14.1.2015, 8:00 p.m.

Write a program that:
• reads in a metabolic network: A struct in a .mat file called "network" with:
• S: the stoichiometric matrix
• rev: the reversibility vector (rev(i) = 0: reaction i is not reversible, rev(i) = 1: reaction i is reversible)
• rxns: names of the reactions
• lb: lower bounds
• ub: upper bounds
• description: name of the network
• reads a second argument that is either BIOMASS or BLOCKED
• reads a third argument that is the output filename.
• depending on the given argument either:
• computes flux distribution that maximizes the biomass production and fulfills the steady state assumption. The network will contain a reaction named "Biomass" whose rate has to be maximized.
• determines for every reaction whether it is blocked or not.
• Output format:
• in BIOMASS mode:
• a cell (or a .txt file) with two columns where each row contains the reaction_id and the corresponding rate
• the first row contains the Biomass reaction, the remaining reactions are ordered according to their index
• in BLOCKED mode:
• a vector which contains the names of the blocked reactions
• they are ordered according to their index

### Exercise 3: n-Queens Problem

Deadline: 28.1.2016, 8:00 p.m.

Write a program that solves the n-Queens Problem:

Place as much queens as possible on a n x n chess board such that no two queens interfere. Thus:
• In each vertical line ...
• In each horizontal line ...
• In each diagonal line ...
... is only one queen allowed.

Use MATLAB and gurobi or glpk.

Write a function board = nQueens(n) that gives you a n x n matrix where the entries are 0 or 1. A 1 deontes that a queen was placed in the corresponding field.
Topic revision: r7 - 19 Jan 2017, AnnikaRoehl