Esempio n. 1
0
        private void PutA(mosek.Task task)
        {
            IEnumerable <int> vars = VariableIndices;
            IEnumerable <int> rows = RowIndices;
            int  mskColIdx         = 0;
            bool rowMult           = false; /*  If true one of the row variable coeficient differ from the default -1 and we must scale with - 1/rc */

            /* for each constraint a 'row' variable 'r' is added. the constraint becomes a^x - r == 0. The coefficient (rc = -1) of the row variable may be changed by the user.
             * This corresponds to multiplying the constraint with - 1/rc */

            foreach (int vid in rows)
            {
                if (GetCoefficient(vid, vid) != -1.0)
                {
                    rowMult = true;
                }
            }

            if (rowMult)
            {
                foreach (int vid in vars)
                {
                    foreach (LinearEntry e in GetVariableEntries(vid))
                    {
                        double mul = -(1.0 / (double)GetCoefficient(e.Index, e.Index));
                        task.putaij(rowMap[e.Index], mskColIdx, (double)e.Value * mul);
                    }
                    mskColIdx++;
                }
            }
            else
            {
                foreach (int vid in vars)
                {
                    foreach (LinearEntry e in GetVariableEntries(vid))
                    {
                        task.putaij(rowMap[e.Index], mskColIdx, (double)e.Value);
                    }
                    mskColIdx++;
                }
            }
        }