AMPL sends only the nonzero constraint coefficients to the solver. Thus it does not have any built-in feature for providing you with the complete constraint matrix M.
With a lot of work, it is possible to implement a "solver" creates and solves a transformed problem. For an example see "Example: shell script as solver for the dual LP" on page 8 of www.ampl.com/REFS/hooking2.pdf.
A better alternative is provided however by several solvers that are able to automatically form and solve the dual, without any special work on your part. For example if you run CPLEX with the setting
option cplex_options 'dual';
or Gurobi with the setting
option gurobi_options 'predual 1';
then the dual problem will be formed and solved. The values of the primal and dual variables of the original problem will then be returned to AMPL.
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of marcm...@googlemail.com
Sent: Tuesday, March 26, 2013 3:55 AM
To: am...@googlegroups.com
Subject: [AMPL 6823] How to transform a primal model to the dual model?
Hallo my friends,
i have a problem with AMPL and can't find an answer in the book.
I have a model with a lot of restrictions and i want to solve the dual problem.
So, i first want to save all my restrictions in one matrix M.
So, i want to define M over {quanitity of all restrictions, quantity of all variables}.
To define the quantities is no problem, but my variables may change from problem to problem.
So, i would like to write it flexible.
For better understanding, one small example:
set T := 1..m;
set I := 1..n;
var x{i in I, t in T};
var y{i in I, j in I, t in T};
var xdual{i in I, t in T};
var ydual{i in I, j in I, t in T};
param N := Quantity of restrictions;
set M := {n in N, xdual{i in I, t in T}, ydual{i in I, j in I, t in T}};
I want to assign the parameters of the restrictions with a for-loop to the parameters xdual and ydual.
for{i in I, t in T}
{
let M[p,xdual[i,t]] := 1;
let M[p,ydual[i,j,t] := -2;
let p := p +1;
}
.
.
.
So, my question is, if it is possible to define the matrix M in such a way?
Or have anyone another idea?
Thank you very much
P.S.: Sorry for my bad English.