Efficient MILP problem reformulation
I am trying to solve the following MILP through LP solve. A link for the
original problem is here
The total number of binary variables = M*N
The total number of real variables = N
The total number of constraints = N + M*N + M
M ~ 10, N ~ 40. (H_i, W_i | i = 1 to N) and T are constants.
minimize sum { CW_k | k = 1, ..., N }
with respect to
C_i_k in { 0, 1 }, Feeder i placed in column k, i = 1, ..., M; k = 1,
..., N
CW_k >= 0, Width of column k //k = 1, ..., N
and subject to
//Total height of each column less than T
// I have already implemented height of present column <= height of prev col
// to avoid duplicate solutions.
[1] sum { H_i * C_i_k | i = 1, ..., M } <= T, k = 1, ..., N
//Width of each column = max( widths of individual feeders in that column)
[2] CW_k >= W_i * C_i_k, i = 1, ..., M; k = 1, ..., N
// Each feeder can be placed in only 1 column.
[3] sum { C_i_k | k = 1, ..., N } = 1, i = 1, ..., M
However, beyond a particular value of N (say 20) lp_solve just appears to
hang. I am told that the above size is pretty much "handle-able" for
solvers.
Is there any way I can re-formulate the above MILP so that it can be
solved more efficiently. I have not tried out other solvers but I guess
the performance shall not vary much.
Any help shall be appreciated.
Thanks!
Monday, 30 September 2013
Linux Speedtest (or download) capable of 10Gbps
Linux Speedtest (or download) capable of 10Gbps
We recently just got some brand new servers from Softlayer out of Dallas
05 that should have 10Gbps connectivity and I'd like to test this claim
against a few locations. Does anyone have any good method of testing this?
I obviously don't expect to see the full 10Gbps due to various factors but
I'd like to see just how good it is.
We recently just got some brand new servers from Softlayer out of Dallas
05 that should have 10Gbps connectivity and I'd like to test this claim
against a few locations. Does anyone have any good method of testing this?
I obviously don't expect to see the full 10Gbps due to various factors but
I'd like to see just how good it is.
Compare and contrast interfaces in Java and Delphi
Compare and contrast interfaces in Java and Delphi
I am a Java developer who has recently been thrust into wearing a Delphi
developer hat.
As is typically the case in such situations, I wind up trying to do things
in Delphi while still using my 'Java' mindset, and I get confounded when
they don't work.
Today's issue is the notion of an interface. In Java, I can define an
interface, give it some methods, and later declare a class that implements
that interface.
I have tried to do the same thing in Delphi, and got my fingers burned. I
declared an interface that extended IInterface. But when it came time to
implement that interface, I was greeted by a number of unimplemented
methods errors for methods I didn't declare (QueryInterface, _AddRef,
_Release).
A little Google told me that I needed to extend the TInterfacedObject
instead of TObject. This made me uneasy because it suggests that I cannot
simply add an interface to some third-party class unless that class
ultimately extends TInterfacedObject.
But now, when it becomes time to set my interfaced object .Free, I'm
getting EInvalidPointer exceptions.
As a result, I'm beginning to conclude that the word interface means
something completely different to a Java developer, and a Delphi
developer.
Can someone who is proficient at both languages enlighten me as to the
differences?
Cheers.
I am a Java developer who has recently been thrust into wearing a Delphi
developer hat.
As is typically the case in such situations, I wind up trying to do things
in Delphi while still using my 'Java' mindset, and I get confounded when
they don't work.
Today's issue is the notion of an interface. In Java, I can define an
interface, give it some methods, and later declare a class that implements
that interface.
I have tried to do the same thing in Delphi, and got my fingers burned. I
declared an interface that extended IInterface. But when it came time to
implement that interface, I was greeted by a number of unimplemented
methods errors for methods I didn't declare (QueryInterface, _AddRef,
_Release).
A little Google told me that I needed to extend the TInterfacedObject
instead of TObject. This made me uneasy because it suggests that I cannot
simply add an interface to some third-party class unless that class
ultimately extends TInterfacedObject.
But now, when it becomes time to set my interfaced object .Free, I'm
getting EInvalidPointer exceptions.
As a result, I'm beginning to conclude that the word interface means
something completely different to a Java developer, and a Delphi
developer.
Can someone who is proficient at both languages enlighten me as to the
differences?
Cheers.
Dates in all activity
Dates in all activity
Hi am using Date picker in more than three class with same validation.
Instead I must write in one class and call that function in other classes
when I required, is it possible Below code for Date picker.
public class MainActivity extends Activity {
private TextView tvDisplayDate;
private Button btnChangeDate;
private int myear;
private int mmonth;
private int mday;
static final int DATE_DIALOG_ID = 999;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setCurrentDateOnView();
addListenerOnButton();
}
// display current date
public void setCurrentDateOnView() {
tvDisplayDate = (TextView) findViewById(R.id.tvDate);
final Calendar c = Calendar.getInstance();
myear = c.get(Calendar.YEAR);
mmonth = c.get(Calendar.MONTH);
mday = c.get(Calendar.DAY_OF_MONTH);
// set current date into textview
tvDisplayDate.setText(new StringBuilder()
// Month is 0 based, just add 1
.append(mmonth + 1).append("-").append(mday).append("-")
.append(myear).append(" "));
}
public void addListenerOnButton() {
btnChangeDate = (Button) findViewById(R.id.btnChangeDate);
btnChangeDate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}
});
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
// set date picker as current date
DatePickerDialog _date = new DatePickerDialog(this,
datePickerListener, myear,mmonth,
mday)
{
@Override
public void onDateChanged(DatePicker view, int year, int
monthOfYear, int dayOfMonth)
{
if (year < myear)
view.updateDate(myear, mmonth, mday);
if (monthOfYear < mmonth && year == myear)
view.updateDate(myear, mmonth, mday);
if (dayOfMonth < mday && year == myear && monthOfYear
== mmonth)
view.updateDate(myear, mmonth, mday);
}
};
return _date;
}
return null;
}
private DatePickerDialog.OnDateSetListener datePickerListener = new
DatePickerDialog.OnDateSetListener() {
// when dialog box is closed, below method will be called.
public void onDateSet(DatePicker view, int selectedYear,
int selectedMonth, int selectedDay) {
myear = selectedYear;
mmonth = selectedMonth;
mday = selectedDay;
// set selected date into textview
tvDisplayDate.setText(new StringBuilder().append(mmonth + 1)
.append("-").append(mday).append("-").append(myear)
.append(" "));
Date dateObject1 = new Date(myear - 1900, mmonth, mday);
Date dateObj2 = new Date(System.currentTimeMillis());
if(dateObject1.before(dateObj2) || dateObject1.equals(dateObj2)){
//the program runs normally
}
else{
new AlertDialog.Builder(MainActivity.this)
.setTitle("Wrong Data Input!")
.setMessage("The end Date must be Before
the start Date, please insert new Date
values")
.setNeutralButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
}
}).show();
}
}
};
}
Hi am using Date picker in more than three class with same validation.
Instead I must write in one class and call that function in other classes
when I required, is it possible Below code for Date picker.
public class MainActivity extends Activity {
private TextView tvDisplayDate;
private Button btnChangeDate;
private int myear;
private int mmonth;
private int mday;
static final int DATE_DIALOG_ID = 999;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setCurrentDateOnView();
addListenerOnButton();
}
// display current date
public void setCurrentDateOnView() {
tvDisplayDate = (TextView) findViewById(R.id.tvDate);
final Calendar c = Calendar.getInstance();
myear = c.get(Calendar.YEAR);
mmonth = c.get(Calendar.MONTH);
mday = c.get(Calendar.DAY_OF_MONTH);
// set current date into textview
tvDisplayDate.setText(new StringBuilder()
// Month is 0 based, just add 1
.append(mmonth + 1).append("-").append(mday).append("-")
.append(myear).append(" "));
}
public void addListenerOnButton() {
btnChangeDate = (Button) findViewById(R.id.btnChangeDate);
btnChangeDate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}
});
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
// set date picker as current date
DatePickerDialog _date = new DatePickerDialog(this,
datePickerListener, myear,mmonth,
mday)
{
@Override
public void onDateChanged(DatePicker view, int year, int
monthOfYear, int dayOfMonth)
{
if (year < myear)
view.updateDate(myear, mmonth, mday);
if (monthOfYear < mmonth && year == myear)
view.updateDate(myear, mmonth, mday);
if (dayOfMonth < mday && year == myear && monthOfYear
== mmonth)
view.updateDate(myear, mmonth, mday);
}
};
return _date;
}
return null;
}
private DatePickerDialog.OnDateSetListener datePickerListener = new
DatePickerDialog.OnDateSetListener() {
// when dialog box is closed, below method will be called.
public void onDateSet(DatePicker view, int selectedYear,
int selectedMonth, int selectedDay) {
myear = selectedYear;
mmonth = selectedMonth;
mday = selectedDay;
// set selected date into textview
tvDisplayDate.setText(new StringBuilder().append(mmonth + 1)
.append("-").append(mday).append("-").append(myear)
.append(" "));
Date dateObject1 = new Date(myear - 1900, mmonth, mday);
Date dateObj2 = new Date(System.currentTimeMillis());
if(dateObject1.before(dateObj2) || dateObject1.equals(dateObj2)){
//the program runs normally
}
else{
new AlertDialog.Builder(MainActivity.this)
.setTitle("Wrong Data Input!")
.setMessage("The end Date must be Before
the start Date, please insert new Date
values")
.setNeutralButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
}
}).show();
}
}
};
}
Sunday, 29 September 2013
is MyISAM or Innodb.. With no future support for MyISAM if my app runs using it should i worry?
is MyISAM or Innodb.. With no future support for MyISAM if my app runs
using it should i worry?
The program is old and was written for MYISAM tables. With several of
these in use, it would be a major effort (and worry about problems
afterward) to switch. As long as I can continue to run older versions of
MySQL is there any other reason to change? I do not need more speed, the
tables are ridiculously small as it is and never had a single problem. I
hate to fix things that aren't broken as they usually are broken afterward
using it should i worry?
The program is old and was written for MYISAM tables. With several of
these in use, it would be a major effort (and worry about problems
afterward) to switch. As long as I can continue to run older versions of
MySQL is there any other reason to change? I do not need more speed, the
tables are ridiculously small as it is and never had a single problem. I
hate to fix things that aren't broken as they usually are broken afterward
Scala: Type Mismatch found, Unit required: Boolean
Scala: Type Mismatch found, Unit required: Boolean
I have been trying to run this code but somehow have hit the wall with
'unit mismatch, boolean expected error'. I have run through various
questions on Stackoverflow but haven't found anything concrete that
answers my question.
def balance(chars: List[Char]): Boolean =
{
var i = 0;
var j = 0;
if (Count(i, j) == 0){
true
}
else{
false
}
def Count(count: Int, Pos: Int): Int =
{
if (Pos == chars.length)
{
count
}
else
{
if (chars(Pos) == '(')
{
Count(count + 1, Pos + 1);
}
else
{
Count(count - 1, Pos - 1);
}
}
}
}
I have been trying to run this code but somehow have hit the wall with
'unit mismatch, boolean expected error'. I have run through various
questions on Stackoverflow but haven't found anything concrete that
answers my question.
def balance(chars: List[Char]): Boolean =
{
var i = 0;
var j = 0;
if (Count(i, j) == 0){
true
}
else{
false
}
def Count(count: Int, Pos: Int): Int =
{
if (Pos == chars.length)
{
count
}
else
{
if (chars(Pos) == '(')
{
Count(count + 1, Pos + 1);
}
else
{
Count(count - 1, Pos - 1);
}
}
}
}
UserControl in XAML with parametrs (Win Store App)
UserControl in XAML with parametrs (Win Store App)
I need to send parametrs to my usercontrol. I now how implement sending
but I don't how to take this parametrs. My code:
<UserControls:ItemTemplateControl Parametr="23"/>
Thanks in advance!
I need to send parametrs to my usercontrol. I now how implement sending
but I don't how to take this parametrs. My code:
<UserControls:ItemTemplateControl Parametr="23"/>
Thanks in advance!
Subscribe to:
Posts (Atom)