Test.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*#include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. int
  5. main( int argc, char *argv[] )
  6. {
  7. char buf[ 128 ];
  8. char x;
  9. char *px = &x;
  10. *px = 100;
  11. if( argc != 2 )
  12. {
  13. printf( "Braucht ein Argument!\n" );
  14. exit( 1 );
  15. }
  16. printf( argv[ 1 ] );
  17. putchar( '\n' );
  18. printf( "x = %d\n", x );
  19. printf( "Eingabe: " );
  20. fflush( stdout );
  21. if( fgets( buf, sizeof buf, stdin ) )
  22. printf( buf );
  23. printf( "x = %d\n", x );
  24. return 0;
  25. }
  26. */
  27. #include <ilcplex/ilocplex.h>
  28. #include <conio.h>
  29. #include <iostream>
  30. using namespace std;
  31. int main()
  32. {
  33. IloEnv env;
  34. IloModel mdl( env );
  35. IloNumVar x1;
  36. IloNumVar x2;
  37. IloRange sum_to_one( env, 1, 1 );
  38. IloObjective obj = IloMaximize( env, 0 );
  39. sum_to_one.setLinearCoef( x1, 1 );
  40. sum_to_one.setLinearCoef( x2, 1 );
  41. obj.setLinearCoef( x1, 2 );
  42. obj.setLinearCoef( x2, 1 );
  43. mdl.add( obj );
  44. mdl.add( sum_to_one );
  45. IloCplex solver( mdl );
  46. solver.solve();
  47. cout << solver.getObjValue() << "\n";
  48. getch();
  49. }