
#include <ilcplex/ilocplex.h>
#include <ilsolver/ilosolver.h>
ILOSTLBEGIN

//max f(x)=x1*x2
//s.t x1*x1+x2 <(=)3
//x1>(=)0 x2>(=)0,
//
//max f(x)=5x1-x1*x1+8x2-2x2*x2
//s.t 3x1+2x2<(=)6
//x1>(=)0, x2>(=)

// ¹®Á¦ ¿Í Ç®ÀÌ¸¦ ¼±ÅÃÇØ¼­ Ç®¾îº¸½Ã±â ¹Ù¶ø´Ï´Ù. 
// ÇöÀç 1-Solver, 2-Cplex ·Î Ç®¸³´Ï´Ù. 
// 

void main ()
{
   IloEnv env;
   try {
      IloModel model(env);

	  IloNumVar X(env, 0, IloInfinity, ILOFLOAT, "X");
	  IloNumVar Y(env, 0, IloInfinity, ILOFLOAT, "Y");

	  //¹®Á¦ 1 ½ÃÀÛ
	  model.add((X*X + Y)<= 3);
	  model.add(IloMaximize(env, (X*Y)));
	  //¹®Á¦ 1 ³¡


	  //¹®Á¦ 2 ½ÃÀÛ
	  //model.add(3*X + 2*Y <= 6);
	  //model.add(IloMaximize(env, (5*X-X*X + 8*Y-2*Y*Y)));
	  //¹®Á¦ 2 ³¡

	  //CPLEX ·Î Ç®ÀÌ
	  /*
	  IloCplex cplex(model);
      if ( cplex.solve() ) {
		  env.out() << "OBJVALUE : " << cplex.getObjValue() << endl;

		  env.out() << cplex.getValue(X) << " : " << cplex.getValue(Y) << endl;

		
		  cplex.exportModel("ABC.lp");
		  cout << " endl " << endl;
      }
	  */
	  //CPLEX ·Î Ç®ÀÌ ³¡

	  // SOLVER ·Î Ç®ÀÌ
	  /*
	  	IloSolver solver(model);
		solver.startNewSearch();
		

		while (solver.next()){};
		solver.endSearch();
		if (solver.solve())
		{
			env.out() << "OBJ : "<< solver.getObjValue() << endl;
				
			env.out() << solver.getValue(X) << " : " << solver.getValue(Y) << endl;

		}
		solver.printInformation();
		*/
		//SOLVER ·Î Ç®ÀÌ³¡

   }
   catch (IloException& e) {
      cerr << "Concert exception caught: " << e << endl;
   }
   catch (...) {
      cerr << "Unknown exception caught" << endl;
   }

   env.end();
}  // END main

