view toolboxes/SVM-light/Readme_optimization_relative_constraints.txt @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
line wrap: on
line source
Solving general optimization problems
-------------------------------------

You can use SVM-light to solve general optimzation problems of the form:

   min 0.5 w*w + C sum_i C_i \xi_i
   s.t. x_i * w > rhs_i - \xi_i

Use the option "-z o". This allows specifying a training set where the examples are the inequality constraints. For example, to specify the problem

   min 0.5 w*w + 10 (1000 \xi_1 + 1 \xi_2 + 1 \xi_3 + 1 \xi_4)
   s.t.	1 w_1 >= 0 - \xi_1
   	-2 w_1 >= 1 - \xi_2
   	2 w_3 >= 2 - \xi_3
   	2 w_2 + 1 w_3 >= 3 - \xi_4

you can use the training set

0 cost:10000 1:1
1 1:-2
2 3:2
3 2:3 3:1

and run 

    svm_learn -c 10 -z o train.dat model 

The format is just like the normal SVM-light format. Each line corresponds to one inequality. However, the first element of each line is the right-hand side of the inequality. The remainder of the line specifies the left-hand side. The parameter cost:<value> is optional and lets you specify a factor by which the value of the slack variable is weighted in the objective. The general regularization parameter (10 in the example) is specified with the option -c <value> on the command line.

To classify new inequalities, you can use svm_classify in the normal way.